MishkaCmsMigration.Resources.Changes.PickedItems (Mishka CMS Migration v0.0.1)

Copy Markdown View Source

Turns the items argument of a run's :dry_run_items or :import_items, the ids of the items an admin picked on the Items page (MishkaCmsMigration.MigrationItem), into what the run's job is handed (MishkaCmsMigration.Resources.Changes.EnqueueJob): their source ids by kind, and the status the run goes back to once the job is done, the one it is in now.

update :import_items do
  change MishkaCmsMigration.Resources.Changes.PickedItems
  change {MishkaCmsMigration.Resources.Changes.EnqueueJob, trigger: :run_import}
end

The items are read in one query, as the admin, among the items of the run's site and source host alone, while the action is built: an id that names none of them is left out, and when none is left the action is refused on items, in words. The run's move is then one atomic update, held by MishkaCmsMigration.Resources.Validations.Status with as_read: true, so a request made with a run read before it moved on, such as a second click on a page drawn before the first, is refused by the database, queues no job, and the status the run goes back to is the one it held.

An admin the CMS's own policies do not let read the records a picked kind is written to (MishkaCmsMigration.Target's resources/0, asked with Ash.can?/3 from the admin's permissions, without a query) is refused on items too, "You may not change tags on this site.", before anything is queued: the job could only fail those items.