admin: fix per-row count queries on admin pages

Closed Beginner friendly
#689 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@jaspermayone is already working on this.

Since Oct 7, 2026.

  • #706 by @jaspermayone — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rails, ruby

Research direction

Start with the listed admin views and their corresponding controller queries, especially the building.rooms.size and faculty.courses.count calls. Add request specs for the affected admin pages with at least two rows so Prosopite can check them. Done means the per-row count queries are eliminated and the specs pass.

Written by the indexing model from the issue text.

Description

performance v/6

Found in the #654 audit. Low priority: admin pages only.

Problem

Some admin pages run one query for each row:

  • app/views/admin/buildings/index.html.erb:122: building.rooms.size for each building.
  • app/views/admin/faculties/missing_rmp_ids.html.erb:66 and app/views/admin_mailer/missing_rmp_ids_summary.html.erb:18: faculty.courses.count for each faculty.
  • app/views/admin/faculties/show.html.erb:138.

Prosopite (#673) now raises on N+1 queries in request specs, so a spec with two or more rows on these pages will fail.

Fix

  1. Use includes and .size, or a grouped count in the controller.
  2. Add request specs with two or more rows, so Prosopite checks these pages.

Effort: small.

Dominant language
Ruby
Stars
4
Forks
0
Avg merge
6h 36m
Merged PRs (30d)
181

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WITCodingClub/calendar-backend

All issues in WITCodingClub/calendar-backend

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.