Skip to content

OTWO-7638 Add performance findings for admin dashboard#1903

Open
kaushak-ai wants to merge 3 commits into
mainfrom
OTWO-7638
Open

OTWO-7638 Add performance findings for admin dashboard#1903
kaushak-ai wants to merge 3 commits into
mainfrom
OTWO-7638

Conversation

@kaushak-ai
Copy link
Copy Markdown

This document outlines the performance issues identified in the admin dashboard, including N+1 queries, expensive window-function job lookups, and missing indexes. Recommendations for optimization are provided, along with a caching strategy and validation plan to measure improvements.

Copy link
Copy Markdown

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

This PR updates admin dashboard stats queries and chart generation to reduce query cost (avoiding join-induced duplicates, reducing grouping work, and improving index usage) while adding defensive handling for missing/zero baselines in percentage calculations.

Changes:

  • Replaces join+distinct.size patterns with EXISTS-based counting for “projects with enlistments” stats (and caches the results).
  • Updates dashboard helper percentage methods to avoid divide-by-zero and normalizes cached values to integers.
  • Refactors admin project chart monthly gap filling to precompute monthly totals and avoid repeated per-month queries; also adjusts date filtering to avoid DATE(created_at) casts.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
lib/tasks/admin_project_stats.rake Changes how “active projects (with enlistments)” is counted and cached.
app/helpers/dashboard_helper.rb Updates cached counts and percentage calculations (including divide-by-zero handling).
app/decorators/oh_admin/project_chart.rb Refactors monthly chart total calculation and simplifies grouped queries.
app/decorators/oh_admin/account_chart.rb Replaces DATE(created_at) predicate with range-friendly timestamp comparison.

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

Comment thread app/decorators/oh_admin/project_chart.rb Outdated
Comment thread app/decorators/oh_admin/project_chart.rb Outdated
Comment thread app/helpers/dashboard_helper.rb
Comment thread lib/tasks/admin_project_stats.rake Outdated
Comment thread lib/tasks/admin_project_stats.rake
Comment thread app/helpers/dashboard_helper.rb
@Priya5 Priya5 changed the title Add performance findings for admin dashboard OTWO-7638 Add performance findings for admin dashboard May 26, 2026
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