Appearance
A cross-row aggregation into a summary entity
When you need this
"Count / sum / average many rows on a schedule and store the result." A nightly inventory reconciliation, per-asset maintenance-cost totals, seats-used per licence. Zero Java — one entity_aggregation_config row run by engine-entity.aggregation-sweep.
The file
metadata/seed-data/office-equipment-aggregation-configs.json (real file):
json
{
"entity": "entity_aggregation_config",
"keyFields": ["sweep_code"],
"source": "office-equipment",
"rows": [
{
"sweep_code": "equipment-status-reconciliation",
"source_entity": "oeq_equipment",
"aggregation": "count",
"group_by_field": "status",
"target_entity": "oeq_reconciliation",
"target_key_field": "metric_key",
"target_key_prefix": "equipment_status:",
"target_value_field": "metric_value",
"target_timestamp_field": "last_reconciled_at",
"active": true
}
]
}Result: one oeq_reconciliation row per status, keyed equipment_status:AVAILABLE, equipment_status:ASSIGNED, … with the count in metric_value.
Variants
sum/avg/min/max— addagg_field(the numeric column).- Write onto the parent row instead of a summary entity — set
target_key_field: "id", leavetarget_key_prefixblank; thegroup_by_fieldvalues are the parent's primary keys. (E.g. sum line-item cost onto the maintenance record's ownsynced_cost.) - Filter first — add
status_field+when_status_in.
Also ship
metadata/entities/oeq_reconciliation.json(the summary entity), and the sharedentity_aggregation_config.json(additive).metadata/rules/ensure_aggregation_sweep_job_registered.json— anAFTER_CREATEEXECUTE_SERVICErule callingensureEntityAggregationSweepJobRegistered(this job does not self-register from a platform rule — you ship it).
Related
- Add a cross-row aggregation job
- A KPI dashboard page — the on-demand version