Skip to content

Revert "[TEMP] Don't make /stats use indexes"#1174

Merged
skyfallwastaken merged 1 commit intomainfrom
revert-1173-interactivity-fix
Apr 15, 2026
Merged

Revert "[TEMP] Don't make /stats use indexes"#1174
skyfallwastaken merged 1 commit intomainfrom
revert-1173-interactivity-fix

Conversation

@skyfallwastaken
Copy link
Copy Markdown
Member

Reverts #1173

Copilot AI review requested due to automatic review settings April 15, 2026 23:37
@skyfallwastaken skyfallwastaken enabled auto-merge (squash) April 15, 2026 23:37
@skyfallwastaken skyfallwastaken merged commit 8173902 into main Apr 15, 2026
13 of 14 checks passed
@skyfallwastaken skyfallwastaken deleted the revert-1173-interactivity-fix branch April 15, 2026 23:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_action hook that disabled index/bitmap/index-only scans for stats requests.
  • Deletes the private helper method that executed SET LOCAL enable_*scan = off inside a transaction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 15, 2026

Greptile Summary

This PR reverts the temporary change from #1173 that bypassed index usage in the /stats endpoint, restoring the original Heartbeat.where(time: start_date..end_date) query path. No new logic is introduced — it is a clean, targeted revert of a single-file [TEMP] workaround.

Confidence Score: 5/5

Safe 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

Filename Overview
app/controllers/api/v1/stats_controller.rb Reverts the temporary index-bypass from #1173; restores Heartbeat.where(time: start_date..end_date) range query with standard index usage.

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]
Loading

Reviews (1): Last reviewed commit: "Revert "[TEMP] Don't make /stats use ind..." | Re-trigger Greptile

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.

2 participants