MishkaCmsMigration.Workers.Helpers.Archived (Mishka CMS Migration v0.0.1)

Copy Markdown View Source

The CMS records an admin archived. A resource with AshArchival.Resource hides an archived record from its reads, so an item that remembers one (MishkaCmsMigration.MigrationItem's target_id or mapped_id) reads as though it were deleted, and a write that points at it, such as a post's tags, is refused as a record "not found".

call/3 finds them through the read the record's Archived tab runs, and restore/2 brings one back through the action its Restore runs: the actions the resource's mishka_gervaz archive configuration names for a site's admin (MishkaGervaz.Resource.Info.Table.archive_action_for/3, :archived and :unarchive unless the resource names others), as the admin running the job, on the run's site and under the CMS's own policies. A resource with no archive has none.

Summary

Functions

The archived records of resource among ids, read as context's actor on its site_id; [] for a resource with no archive and for an admin the CMS does not let read them. One query for each page of the archive read, a page holding up to its largest size.

Restores record as context's actor on its site_id, inside the import's transaction for the item, and answers the record as the CMS restored it.

Functions

call(resource, ids, context)

@spec call(Ash.Resource.t(), [Ecto.UUID.t()], %{actor: term(), site_id: term()}) :: [
  struct()
]

The archived records of resource among ids, read as context's actor on its site_id; [] for a resource with no archive and for an admin the CMS does not let read them. One query for each page of the archive read, a page holding up to its largest size.

restore(record, context)

@spec restore(struct(), %{actor: term(), site_id: term()}) ::
  {:ok, struct()} | {:error, term()}

Restores record as context's actor on its site_id, inside the import's transaction for the item, and answers the record as the CMS restored it.