Skip to content

Project counters missing indexes - #5163

Merged
hlbmtc merged 2 commits into
mainfrom
feat/missing-user-indexes
Aug 31, 2026
Merged

Project counters missing indexes#5163
hlbmtc merged 2 commits into
mainfrom
feat/missing-user-indexes

Conversation

@hlbmtc

@hlbmtc hlbmtc commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Performance
    • Added database indexes to improve forecast, question aggregation, and staff-user lookups.
    • Improved project forecaster counting by excluding staff accounts and accurately combining forecast sources.

@hlbmtc
hlbmtc deployed to testing_env August 31, 2026 13:43 — with GitHub Actions Active
@hlbmtc
hlbmtc deployed to testing_env August 31, 2026 13:43 — with GitHub Actions Active
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a865f89-8d4b-487c-a7af-a471304c0d69

📥 Commits

Reviewing files that changed from the base of the PR and between bdc40e0 and c39aee3.

📒 Files selected for processing (7)
  • posts/migrations/0033_postusersnapshot_posts_postuser_forecasted_idx.py
  • posts/models.py
  • projects/models.py
  • questions/migrations/0038_question_idx_q_id_incl_default_agg.py
  • questions/models.py
  • users/migrations/0024_user_user_is_staff_idx.py
  • users/models.py

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The change adds partial and covering database indexes for forecast, staff, and question aggregation queries. It also rewrites project forecaster counting to exclude staff users and deduplicate users through unioned queries.

Changes

Query performance updates

Layer / File(s) Summary
Snapshot and staff indexes
posts/models.py, posts/migrations/..., users/models.py, users/migrations/...
Adds partial indexes for forecasted post-user snapshots and staff user IDs.
Forecaster count query rewrite
projects/models.py
Excludes staff users and unions default-project and secondary-project snapshot queries before counting unique forecasters.
Question aggregation covering index
questions/models.py, questions/migrations/...
Adds a covering index for question IDs and default_aggregation_method.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to c39ae

The PR adds database indexes and updates internal project forecaster counting without any identified correctness, security, or availability issue; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: lsabor

Poem

A rabbit indexed snapshots with care

Staff IDs vanished from the query air
Forecasters joined in a tidy row
Question lookups gained a faster flow
“Hop!” said the rabbit, “the plans now glow”

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding missing indexes that support project counter queries. It is concise and related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/missing-user-indexes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Cleanup: Preview Environment Removed

The preview environment for this PR has been fully removed.

Resource Status
🌐 Preview App Deleted
🗄️ PostgreSQL Branch Deleted
⚡ Redis Database Deleted
🔧 GitHub Deployments Removed
📦 Docker Image Retained (auto-cleanup via GHCR policies)

Cleanup triggered by PR close at 2026-08-31T14:11:11Z

@hlbmtc
hlbmtc merged commit 86ac48f into main Aug 31, 2026
16 checks passed
@hlbmtc
hlbmtc deleted the feat/missing-user-indexes branch August 31, 2026 14:11
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.

1 participant