Skip to content

OTWO-7667 People page Query optiization#1905

Merged
Priya5 merged 4 commits into
stagingfrom
OTWO-7667
Jun 25, 2026
Merged

OTWO-7667 People page Query optiization#1905
Priya5 merged 4 commits into
stagingfrom
OTWO-7667

Conversation

@bd-vaibhav

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

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 targets People page query optimization by adding a composite index and reducing N+1 queries / expensive counting on the People index page. However, the accompanying db/structure.sql re-dump introduces incompatibilities and suspicious migration bookkeeping changes that will break db:structure:load in CI (PostgreSQL 11) and likely indicates an unintended dump artifact.

Changes:

  • Add a partial composite index on people(name_id, kudo_position) to support People page query patterns.
  • Reduce People index DB work by preloading additional associations and replacing an explicit unclaimed count query with a “fetch 4, show 3” approach.
  • Update structure dump to include the new index (but also includes PG14-specific dump output and duplicated schema_migrations inserts).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
db/structure.sql Adds the new index, but also contains a PG14-specific re-dump and duplicated/shifted schema_migrations inserts (problematic).
db/migrate/20260603065929_add_index_to_people_name_id_kudo_position.rb Adds the intended partial composite index for query optimization.
app/views/people/_people.html.haml Switches “more unclaimed” rendering logic to use @more_unclaimed instead of a count.
app/views/people/_claimed_person.html.haml Attempts to avoid persisting Markup, but current change makes the rendered first line blank.
app/models/person.rb Expands preloads for claimed people; switches some includes to preload for unclaimed relations query.
app/models/account.rb Makes best_account_analysis respect preloaded association when available.
app/helpers/people_helper.rb Preloads projects when building contribution sentences to reduce N+1.
app/controllers/unclaimed_controller.rb Adjusts unclaimed query and forces relation evaluation for memory/behavior consistency.
app/controllers/people_controller.rb Removes count query by fetching one extra unclaimed group and using @more_unclaimed.

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

Comment thread app/views/people/_claimed_person.html.haml Outdated
Comment thread db/structure.sql Outdated
Comment thread db/structure.sql Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment thread app/models/account.rb
Comment thread app/controllers/unclaimed_controller.rb
@bd-vaibhav bd-vaibhav force-pushed the OTWO-7667 branch 2 times, most recently from 1156bdf to cdee65a Compare June 8, 2026 07:09
@bd-vaibhav bd-vaibhav force-pushed the OTWO-7667 branch 6 times, most recently from 33d6a43 to 8bc4aca Compare June 9, 2026 12:50
Comment thread app/controllers/people_controller.rb Outdated
@Priya5 Priya5 changed the base branch from main to staging June 24, 2026 12:01
@Priya5 Priya5 merged commit e391552 into staging Jun 25, 2026
1 check passed
@Priya5 Priya5 deleted the OTWO-7667 branch June 25, 2026 06:57
Priya5 pushed a commit that referenced this pull request Jun 25, 2026
* OTWO-7667 People page Query optimization

* OTWO-7667 Fixed test errors for people page

* OTWO-7667 Cache changes in people page

* OTWO-7667 Removed ApplicationHelper from people controller
Priya5 pushed a commit that referenced this pull request Jun 25, 2026
* OTWO-7667 People page Query optimization

* OTWO-7667 Fixed test errors for people page

* OTWO-7667 Cache changes in people page

* OTWO-7667 Removed ApplicationHelper from people controller
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.

4 participants