Skip to content

feat(aggregation): cumulative/running-total time-bucket aggregates (#2058)#2062

Merged
rubenvdlinde merged 1 commit into
developmentfrom
wip/build-cumulative-aggregates
Jul 24, 2026
Merged

feat(aggregation): cumulative/running-total time-bucket aggregates (#2058)#2062
rubenvdlinde merged 1 commit into
developmentfrom
wip/build-cumulative-aggregates

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Summary

Implements the last open requirement of the adhoc-aggregation-suite OpenSpec change — REQ-AGG-103 cumulative/running-total time-bucket aggregates — and archives the change.

  • Adds a cumulative: true flag to the ad-hoc time-bucket primitive (AggregationQuery, TimeseriesRequestValidator, AggregationController::timeseries()). Only valid alongside a time-bucket (dateBucket) request.
  • Buckets are ordered ascending by bucket start; each group carries its own value plus a running-total cumulative.
  • Postgres: native SQL window — SUM(...) OVER (ORDER BY bucket) — no extra bind parameter (reuses the existing bucket output alias).
  • MySQL / SQLite / PHP fallback: new AggregationRunner::addCumulativeColumn() PHP post-pass over the already-ordered buckets.
  • The two paths are pinned to produce identical output by a dedicated parity test.
  • AggregationQuery::toArray() now carries cumulative, so the ad-hoc cache key differentiates a cumulative request from an otherwise-identical plain request (REQ-AGG-105).
  • Response shape is unchanged when cumulative is absent (regression-pinned).
  • Archives openspec/changes/adhoc-aggregation-suite (all 6 requirements now shipped) and syncs the delta into openspec/specs/aggregation-api/spec.md.
  • Repoints @spec tags that referenced the change directory at the canonical openspec/specs/aggregation-api/spec.md so they survive the archive move.

Closes #2058

Test plan

  • AggregationRunnerCumulativeTest (new, 12 tests): AggregationQuery cumulative validation, Postgres SQL-window emission + wiring, MySQL PHP-post-pass, PHP-fallback running total, SQL-window-vs-PHP-post-pass parity, cache-key differentiation, unchanged-shape-when-absent regression.
  • TimeseriesRequestValidatorTest extended with cumulative parsing/validation cases.
  • Full aggregation-domain unit suite (196 tests) green in the nextcloud:34.0.0-apache container, no regressions.
  • phpcs clean on all touched lib/ files (0 errors; only pre-existing unrelated warnings).
  • openspec validate adhoc-aggregation-suite --strict passed before archive; openspec validate aggregation-api --strict passed after.

Known pre-existing, unrelated CI/test failures (npm lockfile, eslint/stylelint/license/Newman infra, repo-wide phpcs debt, ~18 unrelated local phpunit failures in MapLinkService/PhotoLinkService/PollLinkService/SchemaLinkedTypes/SettingsController/RelationsController/etc, all confirmed present on unmodified origin/development) are out of scope for this change.

…2058)

Implements the last open requirement of adhoc-aggregation-suite (REQ-AGG-103):
a `cumulative: true` flag on the ad-hoc time-bucket primitive that orders
buckets ascending and returns a running total alongside each per-bucket value.

- AggregationQuery gains a `cumulative` flag, valid only alongside a
  dateBucket; carried into the cache-key shape (toArray()) so a cumulative
  request and a plain request never collide in AggregationCache.
- TimeseriesRequestValidator parses/validates the `cumulative` query param
  (requires `interval`); AggregationController::timeseries() wires it through.
- AggregationRunner: Postgres computes the running total natively via
  `SUM(...) OVER (ORDER BY bucket)`; MySQL, SQLite and the PHP fallback use
  the new addCumulativeColumn() PHP post-pass over the already-ordered
  buckets. Both paths are pinned to agree by a dedicated parity test.
- Response shape is unchanged when `cumulative` is absent.
- Archives the adhoc-aggregation-suite OpenSpec change (all 6 requirements
  now shipped) and syncs the delta into openspec/specs/aggregation-api/spec.md.
- Repoints @SPEC tags that referenced the change directory at the canonical
  openspec/specs/aggregation-api/spec.md so they survive the archive move.
@rubenvdlinde
rubenvdlinde merged commit 147723c into development Jul 24, 2026
8 of 17 checks passed
@rubenvdlinde
rubenvdlinde deleted the wip/build-cumulative-aggregates branch July 24, 2026 11:41
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 9732ae0

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
composer ✅ 172/172
npm
PHPUnit ⏭️
Newman ⏭️
Playwright ⏭️

Quality workflow — 2026-07-24 11:45 UTC

Download the full PDF report from the workflow artifacts.

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