Skip to content

feat(clickhouse): extend retention TTL to the events_daily table#27

Merged
loks0n merged 1 commit into
utopia-php:mainfrom
levivannoort:feat/retention-ttl-events-daily
Jul 17, 2026
Merged

feat(clickhouse): extend retention TTL to the events_daily table#27
loks0n merged 1 commit into
utopia-php:mainfrom
levivannoort:feat/retention-ttl-events-daily

Conversation

@levivannoort

Copy link
Copy Markdown
Contributor

What

Follow-up to #24. Generalizes applyEventsRetention() into applyRetention(string $tableName) and applies the same retention window to both the raw *_events table and the aggregated *_events_daily table. Gauges remain untouched.

Why

The raw events TTL alone left the aggregated events_daily table unbounded. Callers that set a retention window now get a single consistent horizon across both tables, so long-term aggregated rows are purged on the same schedule instead of growing forever.

Changes

  • setup() now calls applyRetention() for the events table and the events_daily table.
  • Constructor/method docblocks updated to reflect events + events_daily (gauges excluded).
  • Schema test renamed to testRetentionAppliesTtlToEventsAndDailyTables; asserts events_daily now carries the TTL and gauges does not.

Note

This is a behavior change: with a retention set, aggregated daily history is now bounded by the same window. Consumers relying on events_daily as unbounded long-term history should account for this.

🤖 Generated with Claude Code

Generalize applyEventsRetention into applyRetention(table) and apply the
same window to both the raw events and aggregated events_daily tables;
gauges stay untouched. Update the schema test accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR applies the ClickHouse retention window to aggregated daily events as well as raw events. The main changes are:

  • Generalized the retention helper to accept a table name.
  • Applied retention to both events and events_daily during setup.
  • Updated schema coverage to expect TTL on daily events and no TTL on gauges.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
src/Usage/Adapter/ClickHouse.php Generalizes retention application and applies the same TTL to the daily aggregate table.
tests/Usage/Adapter/ClickHouseSchemaTest.php Updates the retention schema test to cover events, daily events, and gauges.

Reviews (1): Last reviewed commit: "feat(clickhouse): extend retention TTL t..." | Re-trigger Greptile

@loks0n
loks0n merged commit 5b7eb11 into utopia-php:main Jul 17, 2026
4 checks passed
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.

3 participants