PhoenixKit.Modules.Publishing.Workers.MigratePrimaryLanguageWorker (phoenix_kit v1.7.71)

Copy Markdown View Source

Oban worker for migrating posts to a new primary language setting.

This worker updates the primary_language metadata field for all posts in a publishing group that need migration. It processes posts in batches and broadcasts progress updates via PubSub.

Usage

# Enqueue a migration job
MigratePrimaryLanguageWorker.enqueue("docs", "en")

# Or with options
MigratePrimaryLanguageWorker.enqueue("docs", "en", user_uuid: "019145a1-0000-7000-8000-000000000001")

Job Arguments

  • group_slug - The publishing group slug
  • primary_language - The new primary language to set
  • user_uuid - User UUID for audit trail (optional)

PubSub Events

The worker broadcasts the following events to posts_topic(group_slug):

  • {:primary_language_migration_started, total_count} - Migration started
  • {:primary_language_migration_progress, current, total} - Progress update
  • {:primary_language_migration_completed, success_count, error_count} - Completed

Summary

Functions

create_job(group_slug, primary_language, opts \\ [])

Creates a new migration job.

Options

  • :user_uuid - User UUID for audit trail

Examples

MigratePrimaryLanguageWorker.create_job("docs", "en")
MigratePrimaryLanguageWorker.create_job("docs", "en", user_uuid: "019145a1-0000-7000-8000-000000000001")

enqueue(group_slug, primary_language, opts \\ [])

Enqueues a migration job.

See create_job/3 for options.

Examples

{:ok, job} = MigratePrimaryLanguageWorker.enqueue("docs", "en")