Skip to content

feat(analytics): implement time-series granularity selection and enha… - #27

Merged
li4nee merged 1 commit into
mainfrom
staging
Jul 11, 2026
Merged

li4nee merged 1 commit into
mainfrom
staging

Conversation

@li4nee

@li4nee li4nee commented Jul 11, 2026 •

Copy link
Copy Markdown
Owner

…nce time series fetching methods

Summary by CodeRabbit

  • New Features

    • Analytics time-series reports now automatically use fine, hourly, or daily granularity based on the selected date range.
    • Long-range reports include daily summaries for improved readability and performance.
    • Endpoint drilldowns now align with the selected reporting interval and provide consistent hit, error, and latency metrics.
  • Bug Fixes

    • Improved handling of omitted date-range filters by applying appropriate default time windows.
    • Query validation now reliably preserves parsed filter values.

@li4nee
li4nee merged commit c69fad3 into main Jul 11, 2026
2 checks passed
@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6afdd06f-a5db-4fb6-9c17-fc08167dac6f

📥 Commits

Reviewing files that changed from the base of the PR and between 21288fa and 1ebc092.

📒 Files selected for processing (6)
  • server/src/modules/analytics/services/analytics.service.ts
  • server/src/modules/processor/repos/apiHits.repo.ts
  • server/src/modules/processor/repos/apiHitsBase.repo.ts
  • server/src/modules/processor/repos/endpointMetrics.repo.ts
  • server/src/modules/processor/repos/endpointMetricsBase.repo.ts
  • server/src/shared/middleware/zodValidators.middleware.ts

📝 Walkthrough

Walkthrough

Analytics time-series retrieval now selects Mongo fine, PostgreSQL hourly, or PostgreSQL daily aggregation based on range length. Mongo aggregation is shared across endpoints, daily PostgreSQL rollups are added, and validated queries are reassigned through property descriptors.

Changes

Analytics time-series aggregation

Layer / File(s) Summary
Daily PostgreSQL rollup
server/src/modules/processor/repos/endpointMetricsBase.repo.ts, server/src/modules/processor/repos/endpointMetrics.repo.ts
Adds the daily time-series contract and aggregates endpoint metrics by day with numeric conversion and rounded latency.
Shared Mongo bucket aggregation
server/src/modules/processor/repos/apiHitsBase.repo.ts, server/src/modules/processor/repos/apiHits.repo.ts
Introduces configurable epoch-aligned buckets shared by fine and endpoint time-series queries.
Granularity-based dispatch
server/src/modules/analytics/services/analytics.service.ts
Derives default time bounds, selects aggregation granularity, routes requests to the selected repository method, and passes bucket size to endpoint drilldowns.

Query validation assignment

Layer / File(s) Summary
Validated query reassignment
server/src/shared/middleware/zodValidators.middleware.ts
Replaces mutation of req.query with descriptor-based reassignment of the parsed query value.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant AnalyticsService
  participant MongoApiHitsRepo
  participant EndPointMetricsRepo
  Client->>AnalyticsService: request time series with date range
  AnalyticsService->>AnalyticsService: pickGranularity(startTime, endTime)
  alt mongo-fine
    AnalyticsService->>MongoApiHitsRepo: getFineTimeSeries(bucketMs)
  else postgres-hourly
    AnalyticsService->>EndPointMetricsRepo: getTimeSeries()
  else postgres-daily
    AnalyticsService->>EndPointMetricsRepo: getDailyTimeSeries()
  end
  AnalyticsService-->>Client: time-series response
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch staging

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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