Skip to content

feat(hardware): add daily hardware aggregates recomputed from raw - #2037

Open
alanpeixinho wants to merge 4 commits into
mainfrom
feat/hardware-daily-aggregates
Open

alanpeixinho wants to merge 4 commits into
mainfrom
feat/hardware-daily-aggregates

Conversation

@alanpeixinho

@alanpeixinho alanpeixinho commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What it is

Adds daily hardware aggregate tables (hardware_daily_builds, hardware_daily_tests) built from raw checkouts / builds / tests.

  • recompute_hardware_daily: idempotent per-day rebuild (DELETE + INSERT). Uses temp tables so the raw join runs once per day. Advisory locks avoid concurrent collisions. If raw is pruned but aggregates
    exist, keeps the stale rows.
  • Cron: hourly --days=1 (today), every 6h --days=7 — no 60-day batch.
  • prune_db: can prune aggregates by checkout_day independently of raw.
  • update_db / seed_test_data: snapshot/restore and seed support for the new tables.
  • hardware_status: unchanged — still written and read as before.

Closes #2034.

How to test

migrate

Run local database and apply migration

manual recompute

python manage.py recompute_hardware_daily --day=2025-07-18
python manage.py recompute_hardware_daily --days=7

verify rows

Check that the aggregate counts for builds, boots and tests match the sum of the raw tables (builds and tests).

prune dry-run (aggregates only)

python manage.py prune_db --older-than "30 days" \ --tables hardware_daily_builds,hardware_daily_tests --dry-run

@alanpeixinho
alanpeixinho force-pushed the feat/hardware-daily-aggregates branch 3 times, most recently from 39d0d5b to 27eb2e6 Compare August 17, 2026 21:59
@alanpeixinho alanpeixinho changed the title feat(hardware): add daily hardware aggregates recomputed from raw [WIP] feat(hardware): add daily hardware aggregates recomputed from raw Aug 17, 2026
@alanpeixinho
alanpeixinho marked this pull request as ready for review August 17, 2026 22:10
@alanpeixinho
alanpeixinho marked this pull request as draft August 17, 2026 22:13
@alanpeixinho
alanpeixinho marked this pull request as ready for review August 25, 2026 12:59
@alanpeixinho
alanpeixinho force-pushed the feat/hardware-daily-aggregates branch from b5c7772 to 89f9401 Compare August 25, 2026 14:36

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--origins does not apply to hardware_daily_* ?

Those tables are in the default --tables set and are deleted with only checkout_day < cutoff. running prune_db --older-than "30 days" --origins maestro (the docs example) can wipe every origin’s daily aggregates while leaving other tenants’ raw rows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Daily prune was ignoring --origins and deleting by checkout_day only. Fixed in c9392fbhardware_daily_* now filter on checkout_origin the same way raw rows use origin.

@alanpeixinho
alanpeixinho force-pushed the feat/hardware-daily-aggregates branch 2 times, most recently from ea02b2d to c9392fb Compare September 2, 2026 17:29
@alanpeixinho alanpeixinho changed the title [WIP] feat(hardware): add daily hardware aggregates recomputed from raw feat(hardware): add daily hardware aggregates recomputed from raw Sep 4, 2026
- Add daily aggregate tables and recompute_hardware_daily (idempotent, locked,
  keeps rows when raw is pruned)
- Materialize day_tests once per day so both aggregate inserts share one raw scan
- Cron: hourly for today, every 6h for the last 7 days (drop the 60-day run)
- Wire prune_db, seed_test_data and update_db for the new tables
- Leave hardware_status written and read as before

Closes #2034

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Store checkout origin so listings can filter without a join, rebuild
fifteen days for late tests, and drop the unused healthcheck. ANALYZE
the day temp table and raise work_mem in the cron txn so the planner
hashes instead of spilling.

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
* filter hardware_daily_* by checkout_origin when --origins is set
* align dry-run count table columns
* add integration test for origin-scoped daily prune

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Resolves conflicting 0019 leaf nodes after rebasing onto main so CI can run migrate.

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
@alanpeixinho
alanpeixinho force-pushed the feat/hardware-daily-aggregates branch from ac58f3a to 43c8bc7 Compare September 23, 2026 12:57

This branch has not been deployed

No deployments
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.

HW-list: split hardware_status (migration + aggregations)

2 participants