ReactiveDag.Node.Recompute.Aggregate (reactive_dag v0.16.0)

Copy Markdown View Source

Runs a pure-Ash-query aggregate node: the datastore groups + aggregates the node's over relationship in ONE query (a relationship aggregate — Postgres does the GROUP BY), and each parent row's aggregate values become its payload.

The node's resource is the group's own resource — ONE row per group, aggregating the finer rows reached through over. The runner:

  1. reads that resource with the relationship aggregates loaded under temporary names (Ash.Query.aggregate(q, tmp, kind, over, field: src)),
  2. for each row, projects the loaded aggregates onto the resource's own attributes (the dest in each mapping), upserts the row (via ReactiveDag.Node.Payload), and Op.puts the changed keys.

It is a WHOLE-CELL recompute: a GROUP BY reprices every group, so the changed set is every group whose aggregate value actually moved (Payload's change- detection filters the no-ops).

Summary

Functions

Recompute an aggregate node; returns the changed keys.

Functions

recompute(cell, resource, agg)

@spec recompute(ReactiveDag.Cell.t(), module(), map()) :: [String.t()]

Recompute an aggregate node; returns the changed keys.