KamoCRM

Grouped aggregate queries for the agent scorecard

Featurekamo-shared-library
Shipped
22 ஜூலை, 2026 அன்று 5:18 PM UTC
Author
Kamo
Commit
8e83ad9

Twelve @Query aggregates across sessions, messages, usage records and outbound touches, so a scorecard is a handful of grouped queries rather than loading rows into memory. Two properties are enforced in the predicates rather than left to callers: - **isTest sessions are excluded in the query itself.** On a young agent the author's own test drives would otherwise be most of the data, and a caller who forgets to filter produces numbers that look real and are not. - **count(costEstimate) counts only NON-NULL costs.** That is what lets the scorecard distinguish 'nothing was priced' from 'it cost zero' - collapsing those would put a confident $0.00 in front of an org whose traffic simply predates pricing. Outbound touches are grouped by decision rather than filtered to sends. The refusals are the more interesting half: an agent whose touches are nearly all SUPPRESSED_QUIET_HOURS is misconfigured, and that is invisible if decoders are discarded.

All changes

Like what you see shipping?

All of it arrives in your workspace on its own. Start on the free plan and read this page again in a month.

Start Free ForeverView Pricing