| Line 124... |
Line 124... |
| 124 |
// ---- LMS dashboard aggregation (SOP §18) -------------------------------------------------
|
124 |
// ---- LMS dashboard aggregation (SOP §18) -------------------------------------------------
|
| 125 |
// All aggregates bucket EVERY lead: rows with a real `stage` use it; legacy rows (stage NULL)
|
125 |
// All aggregates bucket EVERY lead: rows with a real `stage` use it; legacy rows (stage NULL)
|
| 126 |
// derive a stage from `status` in SQL, mirroring LeadStage.fromLegacy. Read-only, no schema change.
|
126 |
// derive a stage from `status` in SQL, mirroring LeadStage.fromLegacy. Read-only, no schema change.
|
| 127 |
|
127 |
|
| 128 |
/** (derivedStage, count) for the optional region + created-date window. */
|
128 |
/** (derivedStage, count) for the optional region + created-date window. */
|
| 129 |
java.util.List<Object[]> countByDerivedStage(Integer regionId, LocalDateTime from, LocalDateTime to);
|
129 |
java.util.List<Object[]> countByDerivedStage(Integer regionId, Integer agentId, LocalDateTime from, LocalDateTime to);
|
| 130 |
|
130 |
|
| 131 |
/** (derivedStage, SUM(potential)) for the optional region + window — for the onboarded-value KPI. */
|
131 |
/** (derivedStage, SUM(potential)) for the optional region + window — for the onboarded-value KPI. */
|
| 132 |
java.util.List<Object[]> sumPotentialByDerivedStage(Integer regionId, LocalDateTime from, LocalDateTime to);
|
132 |
java.util.List<Object[]> sumPotentialByDerivedStage(Integer regionId, Integer agentId, LocalDateTime from, LocalDateTime to);
|
| 133 |
|
133 |
|
| 134 |
/** (regionCode, derivedStage, count) across all regions in the window — feeds the state funnel. */
|
134 |
/** (regionCode, derivedStage, count) across all regions in the window — feeds the state funnel. */
|
| 135 |
java.util.List<Object[]> countByRegionAndDerivedStage(LocalDateTime from, LocalDateTime to);
|
135 |
java.util.List<Object[]> countByRegionAndDerivedStage(LocalDateTime from, LocalDateTime to);
|
| 136 |
|
136 |
|
| 137 |
/** (regionCode, totalWithDue, onTime) — first-contact SLA compliance per region. */
|
137 |
/** (regionCode, totalWithDue, onTime) — first-contact SLA compliance per region. */
|
| Line 143... |
Line 143... |
| 143 |
/** (derivedStage, count) of OPEN leads not touched since {@code olderThan} — the ageing widget. */
|
143 |
/** (derivedStage, count) of OPEN leads not touched since {@code olderThan} — the ageing widget. */
|
| 144 |
java.util.List<Object[]> ageingByDerivedStage(LocalDateTime olderThan);
|
144 |
java.util.List<Object[]> ageingByDerivedStage(LocalDateTime olderThan);
|
| 145 |
|
145 |
|
| 146 |
/** Single row of conditional-sum attention counts (see impl) for the optional region. */
|
146 |
/** Single row of conditional-sum attention counts (see impl) for the optional region. */
|
| 147 |
/** Attention-queue counts for the region and created-date window (same scope as the funnel). */
|
147 |
/** Attention-queue counts for the region and created-date window (same scope as the funnel). */
|
| 148 |
Object[] attentionCounts(Integer regionId, LocalDateTime now, LocalDateTime nowPlus1h,
|
148 |
Object[] attentionCounts(Integer regionId, Integer agentId, LocalDateTime now, LocalDateTime nowPlus1h,
|
| 149 |
LocalDateTime from, LocalDateTime to);
|
149 |
LocalDateTime from, LocalDateTime to);
|
| 150 |
|
150 |
|
| 151 |
/**
|
151 |
/**
|
| 152 |
* Per-owner lead counters for the live board: {@code [authId, assigned, slaBreached]}.
|
152 |
* Per-owner lead counters for the live board: {@code [authId, assigned, slaBreached]}.
|
| 153 |
* Breached = open, past its first-contact deadline, never contacted.
|
153 |
* Breached = open, past its first-contact deadline, never contacted.
|
| 154 |
*/
|
154 |
*/
|
| 155 |
List<Object[]> selectAgentLeadCounters(LocalDateTime now);
|
155 |
List<Object[]> selectAgentLeadCounters(LocalDateTime now);
|
| 156 |
|
156 |
|
| 157 |
/** Lead ids for a drill-down bucket (STAGE / ATTENTION / REGION), newest first, capped at {@code limit}. */
|
157 |
/** Lead ids for a drill-down bucket (STAGE / ATTENTION / REGION), newest first, capped at {@code limit}. */
|
| 158 |
java.util.List<Integer> selectLeadIdsForBucket(String bucketType, String bucketKey, Integer regionId,
|
158 |
java.util.List<Integer> selectLeadIdsForBucket(String bucketType, String bucketKey, Integer regionId, Integer agentId,
|
| 159 |
LocalDateTime now, LocalDateTime nowPlus1h,
|
159 |
LocalDateTime now, LocalDateTime nowPlus1h,
|
| 160 |
LocalDateTime from, LocalDateTime to, int offset, int limit);
|
160 |
LocalDateTime from, LocalDateTime to, int offset, int limit);
|
| 161 |
|
161 |
|
| 162 |
/** Total leads in the same drill bucket, so the drawer can page through all of them. */
|
162 |
/** Total leads in the same drill bucket, so the drawer can page through all of them. */
|
| 163 |
long countLeadsForBucket(String bucketType, String bucketKey, Integer regionId,
|
163 |
long countLeadsForBucket(String bucketType, String bucketKey, Integer regionId, Integer agentId,
|
| 164 |
LocalDateTime now, LocalDateTime nowPlus1h,
|
164 |
LocalDateTime now, LocalDateTime nowPlus1h,
|
| 165 |
LocalDateTime from, LocalDateTime to);
|
165 |
LocalDateTime from, LocalDateTime to);
|
| 166 |
|
166 |
|
| 167 |
/**
|
167 |
/**
|
| 168 |
* Effective LMS stage per lead id, computed with the same evidence-aware expression the dashboard
|
168 |
* Effective LMS stage per lead id, computed with the same evidence-aware expression the dashboard
|