Revert "[TEMP] Don't make /stats use indexes"#1174
Conversation
This reverts commit 0e2d69e.
There was a problem hiding this comment.
Pull request overview
Reverts the temporary workaround introduced in #1173 that forced PostgreSQL to avoid index scans for certain stats endpoints, restoring normal query planner behavior for /api/v1/stats and related actions.
Changes:
- Removes the
around_actionhook that disabled index/bitmap/index-only scans for stats requests. - Deletes the private helper method that executed
SET LOCAL enable_*scan = offinside a transaction.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis PR reverts the temporary change from #1173 that bypassed index usage in the Confidence Score: 5/5Safe to merge — this is a clean revert of a single-file temporary workaround with no new logic introduced. No new logic, no schema changes, no test gaps. The revert removes a [TEMP] label commit and restores proven, pre-existing behavior. All remaining observations are pre-existing and outside the scope of this PR. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[GET /api/v1/stats] --> B{ensure_authenticated!}
B -- Unauthorized --> C[401 Unauthorized]
B -- Authorized --> D[parse start_date / end_date]
D --> E[Heartbeat.where time: start_date..end_date]
E --> F{username param?}
F -- Yes --> G[User.lookup_by_identifier]
G --> H{User found?}
H -- No --> I[404 Not Found]
H -- Yes --> J[query.where user_id: user.id]
F -- No --> K{user_email param?}
K -- Yes --> L[find user_id by email]
L --> M{user_id found?}
M -- No --> N[404 Not Found]
M -- Yes --> O[query.where user_id: user_id]
K -- No --> P[query unchanged]
J --> Q[query.duration_seconds]
O --> Q
P --> Q
Q --> R[render plain: duration_seconds]
Reviews (1): Last reviewed commit: "Revert "[TEMP] Don't make /stats use ind..." | Re-trigger Greptile |
Reverts #1173