Skip to content

feat(reporting): functional advanced reporting endpoints - #80

Merged
mpge merged 1 commit into
mainfrom
feat/reporting-endpoints
Aug 2, 2026
Merged

feat(reporting): functional advanced reporting endpoints#80
mpge merged 1 commit into
mainfrom
feat/reporting-endpoints

Conversation

@mpge

@mpge mpge commented Aug 2, 2026

Copy link
Copy Markdown
Member

Summary

AdvancedReportingService previously contained only static percentile / composite-score / date-series math helpers — no data access and no HTTP surface, so no analytics could actually be retrieved. This PR makes advanced reporting functional and reachable by adding the missing layers around those helpers, mirroring the report surface of the Laravel host (ReportingService + Admin\ReportController).

What was added

  • Repository aggregation queries (portable JPQL, mirroring existing query style):
    • TicketRepository: created/resolved counts (countCreatedSince, countResolvedSince, *Between), grouped counts (countByStatusSince, countByPrioritySince, countByChannelSince), timing projections (firstResponseTimings, resolutionTimings, createdAtSince), SLA counts (countWithSlaSince, countFirstResponseBreaches, countResolutionBreaches, countSlaBreaches, countSla*ByPriority), and per-agent aggregates (agentTicketCounts, agentFirstResponseTimings). A shared SLA_BREACH_PREDICATE constant keeps the breach logic in one place.
    • SatisfactionRatingRepository: avgRatingSince, countRatingsSince, countByRatingSince, ratingRowsSince, avgRatingByAgentSince.
  • Service methods on AdvancedReportingService (now a @Service) that pipe those datasets through the existing math helpers — calculatePercentiles, compositeScore, dateSeries, calculateChanges are all reused. The static helpers are untouched (their unit tests still pass).
  • JSON report DTOs (dev.escalated.dto.reporting, snake_case via @JsonProperty).
  • AdminReportController at /escalated/api/admin/reports/*, admin-secured by the existing /escalated/api/** token filter chain like every other admin controller.

Endpoints

Endpoint Report
GET /escalated/api/admin/reports/overview totals, avg FRT/resolution, SLA compliance, CSAT, status/priority/channel counts
GET /escalated/api/admin/reports/sla compliance rate, FRT/resolution/total breaches, per-priority breach rates
GET /escalated/api/admin/reports/first-response-time histogram, percentiles, daily trend
GET /escalated/api/admin/reports/resolution-time histogram, percentiles, daily trend
GET /escalated/api/admin/reports/csat average, response rate, rating breakdown, daily trend
GET /escalated/api/admin/reports/volume zero-filled daily series, priority/channel cohorts
GET /escalated/api/admin/reports/agent-performance ranked agents with composite score
GET /escalated/api/admin/reports/period-comparison current vs. previous period, % changes

All take an optional days param (default 30).

Tests (TDD, run locally with ./gradlew check — green)

  • AdvancedReportingServiceDbTest (@DataJpaTest): seeds a deterministic set of tickets/ratings and asserts each report's exact numbers (counts, avg hours, p50, SLA breach counts, composite ranking).
  • AdminReportControllerTest: drives the real controller → service → repositories over a seeded H2 database through MockMvc, asserting each endpoint returns a populated JSON report.

No regressions; full check (all tests + checkstyle) passes.

… endpoints

Wire AdvancedReportingService's static math helpers to real data: add JPQL
aggregation queries on TicketRepository and SatisfactionRatingRepository, new
report-building service methods that feed those datasets through the existing
percentile/composite-score/date-series/period-change helpers, JSON report DTOs,
and an admin-secured AdminReportController exposing per-report endpoints
(overview, SLA, first-response time, resolution time, CSAT, volume, agent
performance, period comparison).

Tests: a @DataJpaTest asserting each report is correct over seeded tickets, and
an end-to-end MockMvc test driving the real controller/service/repositories over
a seeded database.
@mpge
mpge merged commit 1eaacdf into main Aug 2, 2026
2 checks passed
@mpge
mpge deleted the feat/reporting-endpoints branch August 2, 2026 03:26
mpge added a commit that referenced this pull request Aug 2, 2026
… endpoints (#80)

Wire AdvancedReportingService's static math helpers to real data: add JPQL
aggregation queries on TicketRepository and SatisfactionRatingRepository, new
report-building service methods that feed those datasets through the existing
percentile/composite-score/date-series/period-change helpers, JSON report DTOs,
and an admin-secured AdminReportController exposing per-report endpoints
(overview, SLA, first-response time, resolution time, CSAT, volume, agent
performance, period comparison).

Tests: a @DataJpaTest asserting each report is correct over seeded tickets, and
an end-to-end MockMvc test driving the real controller/service/repositories over
a seeded database.

Co-authored-by: Matt Gros <mpge@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant