Skip to content

Improved assignment summary loading time#7899

Merged
david-yz-liu merged 1 commit into
masterfrom
assignment-summary-performance-improvements
Apr 6, 2026
Merged

Improved assignment summary loading time#7899
david-yz-liu merged 1 commit into
masterfrom
assignment-summary-performance-improvements

Conversation

@david-yz-liu

@david-yz-liu david-yz-liu commented Apr 5, 2026

Copy link
Copy Markdown
Collaborator

Proposed Changes

(Describe your changes here. Also describe the motivation for your changes: what problem do they solve, or how do they improve the application or codebase? If this pull request fixes an open issue, use a keyword to link this pull request to the issue.)

This improves the efficiency of the Assignment#summary_json method, which is used in the AssignementsController#summary route (json format). Notable changes are:

  • Fixed an N+1 query for loading result marks
  • Avoid allocations of model objects (e.g., Result, Grouping), instead preferring Ruby arrays/hashes
  • Prefer using pluck to pluck_to_hash
  • Leverage more postgres aggregation functions to group data, rather than Ruby's Enumerable#group_by method
  • Eliminate redundant queries for total mark calculations and number assigned/marked (for instructors only)

On my development environment with ~1200 students and groups, these changes reduced the number of queries from 1248 to 27 and response time from ~5000ms to ~400ms when this summary is invoked by an instructor.

Screenshots of your changes (if applicable)
Associated documentation repository pull request (if applicable)

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality) X
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@coveralls

coveralls commented Apr 5, 2026

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 24015769742

Details

  • 34 of 35 (97.14%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 91.709%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/models/assignment.rb 34 35 97.14%
Totals Coverage Status
Change from base Build 24007090062: 0.0%
Covered Lines: 45176
Relevant Lines: 48452

💛 - Coveralls

@david-yz-liu david-yz-liu force-pushed the assignment-summary-performance-improvements branch 2 times, most recently from 6727d9b to 275811b Compare April 5, 2026 17:15
@david-yz-liu david-yz-liu force-pushed the assignment-summary-performance-improvements branch from 275811b to 9a1c113 Compare April 6, 2026 02:03
@david-yz-liu david-yz-liu added this to the v2.9.6 milestone Apr 6, 2026
@david-yz-liu david-yz-liu merged commit b080f6e into master Apr 6, 2026
11 checks passed
@david-yz-liu david-yz-liu deleted the assignment-summary-performance-improvements branch April 6, 2026 02:28
Naragod added a commit that referenced this pull request Apr 8, 2026
* build(deps): bump loofah from 2.25.0 to 2.25.1 (#7870)

Bumps [loofah](https://github.com/flavorjones/loofah) from 2.25.0 to 2.25.1.
- [Release notes](https://github.com/flavorjones/loofah/releases)
- [Changelog](https://github.com/flavorjones/loofah/blob/main/CHANGELOG.md)
- [Commits](flavorjones/loofah@v2.25.0...v2.25.1)

---
updated-dependencies:
- dependency-name: loofah
  dependency-version: 2.25.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Improved assignment list loading time (#7868)

* build(deps): bump picomatch (#7879)

Bumps  and [picomatch](https://github.com/micromatch/picomatch). These dependencies needed to be updated together.

Updates `picomatch` from 2.3.1 to 2.3.2
- [Release notes](https://github.com/micromatch/picomatch/releases)
- [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md)
- [Commits](micromatch/picomatch@2.3.1...2.3.2)

Updates `picomatch` from 4.0.3 to 4.0.4
- [Release notes](https://github.com/micromatch/picomatch/releases)
- [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md)
- [Commits](micromatch/picomatch@2.3.1...2.3.2)

---
updated-dependencies:
- dependency-name: picomatch
  dependency-version: 2.3.2
  dependency-type: indirect
- dependency-name: picomatch
  dependency-version: 4.0.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump json from 2.18.1 to 2.19.2 (#7871)

Bumps [json](https://github.com/ruby/json) from 2.18.1 to 2.19.2.
- [Release notes](https://github.com/ruby/json/releases)
- [Changelog](https://github.com/ruby/json/blob/master/CHANGES.md)
- [Commits](ruby/json@v2.18.1...v2.19.2)

---
updated-dependencies:
- dependency-name: json
  dependency-version: 2.19.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Modified LTI roster sync to update info for existing users (#7865)

* Fix localization error in batch test run table for in-progress runs (#7869)

Co-authored-by: Mateo <[email protected]>

* Fixed Assignment Summary table filtering (#7880)

Fixes #7822

* Improved assignment summary loading time (#7899)

* v2.9.6

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Liu <[email protected]>
Co-authored-by: donny-wong <[email protected]>
Co-authored-by: Mateo <[email protected]>
Co-authored-by: Karl-A. Michaud <[email protected]>
Co-authored-by: Donny Wong <[email protected]>
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