MishkaDocument.Resources.Helpers.SiteNames (Mishka Document v0.0.1)

Copy Markdown View Source

Ash preparation that resolves, for the whole page in ONE query, the site name the master's site badge (event_site column) shows on each event-log row.

A row's site_id lives in its JSONB metadata/data, not a column or relationship, so it cannot be preloaded and a naive column would read one MishkaCmsCore.Runtime.Site per row. This after_action instead gathers every distinct id on the page, reads all their names at once (:read_any, tenancy bypassed — it only names the master's own badge and never widens which rows a viewer sees), and stamps the resolved display name onto each record's metadata (:site_name); the column then just reads it.

Only a master (a user whose site_id is nil) sees the badge, so every other read, a tenant's or one with no actor, skips the lookup entirely. A page with no site_ids does no read at all, and a site that no longer exists falls back to a truncated id.

See MishkaDocument.EventLog and MishkaCmsCoreWeb.Templates.ActivityTimeline.

Summary

Functions

init(opts)

Callback implementation for Ash.Resource.Preparation.init/1.

supports(opts)

Callback implementation for Ash.Resource.Preparation.supports/1.

temporal_safe?(opts)

Callback implementation for Ash.Resource.Preparation.temporal_safe?/1.