This commit is contained in:
Stefanescu Mihai
2026-03-19 14:53:54 +02:00
parent 4390d43acb
commit d75cabfeec
11 changed files with 717 additions and 76 deletions
+6 -6
View File
@@ -106,14 +106,14 @@ The `CollectController` currently does synchronous DB writes. This won't scale u
Raw event tables grow fast. Pre-aggregate data for fast dashboard loads.
- [ ] Create `daily_aggregates` table (migration + model):
- [x] Create `daily_aggregates` table (migration + model):
- `website_id`, `date`, `visitors`, `sessions`, `page_views`, `bounce_count`, `total_duration`
- [ ] Create `page_daily_aggregates` table:
- [x] Create `page_daily_aggregates` table:
- `website_id`, `date`, `path`, `views`, `unique_views`, `total_time_on_page`, `bounces`
- [ ] Create a scheduled Artisan command (`analytics:aggregate`) that rolls up yesterday's raw data into aggregate tables — run daily via `schedule:run`
- [ ] Refactor dashboard and report queries to read from aggregates for past days, and query raw tables only for "today"
- [ ] Add database indexes review — ensure all date-range + website_id queries are covered
- [ ] Consider adding a `data_retention_days` setting per website and a cleanup command to purge old raw rows
- [x] Create a scheduled Artisan command (`analytics:aggregate`) that rolls up yesterday's raw data into aggregate tables — run daily via `schedule:run`
- [x] Refactor dashboard and report queries to read from aggregates for past days, and query raw tables only for "today"
- [x] Add database indexes review — ensure all date-range + website_id queries are covered
- [x] Add `data_retention_days` setting per website (stored in `settings` JSON) and a cleanup command (`analytics:purge`) to purge old raw rows
---