Skip to content

Fix N+1, Bump minimatch, trix, dompurify, immutable, and undici dependencies#193

Merged
rsmoke merged 2 commits intomainfrom
staging
Mar 17, 2026
Merged

Fix N+1, Bump minimatch, trix, dompurify, immutable, and undici dependencies#193
rsmoke merged 2 commits intomainfrom
staging

Conversation

@rsmoke
Copy link
Copy Markdown
Member

@rsmoke rsmoke commented Mar 17, 2026

This pull request improves how contest descriptions and their related data are loaded and displayed, focusing on optimizing database queries and making entry counts more accurate. The main changes involve eager loading related models to reduce N+1 queries, refining how active contest descriptions are selected, and improving the logic for counting entries.

Performance and Query Optimization:

  • In ContainersController#show, contest descriptions are now eager-loaded with their contest_instances and associated entries to minimize N+1 query issues when displaying contest details.

Logic Improvements:

  • The selection of active contest descriptions now uses Ruby's select(&:active?) on already loaded descriptions, ensuring only the relevant, active ones are processed.
  • In ContestDescriptionsHelper, the method for finding the first active contest instance now uses detect(&:active?) for efficiency and clarity.
  • Entry counts for active contest instances now use Ruby's reject(&:deleted).size instead of a database query, ensuring only non-deleted entries are counted and improving consistency with in-memory objects.
  • The summary of contest descriptions now uses select(&:active?) rather than a database query, aligning with the eager-loaded data and reducing redundant queries.

rsmoke added 2 commits March 17, 2026 16:31
…ed performance and clarity

- Updated the ContainersController to include contest instances in the retrieval of contest descriptions, optimizing data loading and reducing N+1 query issues.
- Enhanced the ContestDescriptionsHelper to simplify the logic for determining active contest instances and counting entries, improving code readability and maintainability.

These changes enhance the efficiency of contest descriptions handling and improve the overall user experience.
Refactor contest descriptions retrieval and helper methods for improv…
@rsmoke rsmoke merged commit b0826ef into main Mar 17, 2026
8 checks passed
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