Manage submissions speed
Description
This changes implements server-side pagination for the manage submissions page to improve loading times.
Motivation and Context
Previously, it would take about 1.5 seconds for each page of the manage submissions page to load since we would render all of them at once. For example, for a submissions page with 400 submissions, it would take about 6 seconds. This change renders only one page at a time, to take a maximum of 1.5 seconds each time.
How Has This Been Tested?
Tested all of the manage submissions functions locally
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [x] I have run rubocop and erblint for style check. If you haven't, run
overcommit --install && overcommit --signto use pre-commit hook for linting - [ ] My change requires a change to the documentation, which is located at Autolab Docs
- [ ] I have updated the documentation accordingly, included in this PR
π Walkthrough
Walkthrough
Switched the submissions index to DataTables server-side rendering. Controller now serves paginated/searchable/sortable JSON and a new row formatter. Client JS manages selection state, delegated events, dynamic row rendering, and batch-action enablement. View removed server-rendered rows and provides header + select-all UI.
Changes
| Cohort / File(s) | Summary |
|---|---|
Server-side DataTables & Controller app/controllers/submissions_controller.rb |
Added JSON handling for DataTables (paging, search by email, multi-column sort including computed score), computes recordsTotal/recordsFiltered, and introduced format_submission_for_datatable(submission, score = nil); declared action_auth_level for new action; removed prior per-request caching logic. |
Client DataTables Initialization & Selection State app/assets/javascripts/manage_submissions.js |
Replaced legacy DataTable init with serverSide/ajax; added selectedStudentCids, selectedSubmissions, submissions_to_cud; implemented columns, createdRow, drawCallback, delegated handlers for dynamic elements; added toggleAllRows, toggleRow, updateSelectAllCheckbox, and updateSelectedCount; removed old pagination/hardcoded-row hacks. |
View: Table Header & Template Simplification app/views/submissions/index.html.erb |
Removed server-rendered tbody and per-row markup, selected-count placeholder, and Regrade All block; simplified header generation to include select-all checkbox and sortable headers; retained modals/placeholders for annotations. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant Browser as Browser (manage_submissions.js)
participant Server as Server (SubmissionsController)
participant DB as Database
rect rgba(230,245,255,0.8)
Note over User,Browser: Initial page load (HTML)
User->>Browser: GET /submissions
Browser->>Server: GET /submissions (HTML)
Server->>DB: Query scaffold data (limited)
DB-->>Server: Return scaffold
Server-->>Browser: Render index view (DataTables config + headers)
Browser->>Browser: Initialize DataTables (serverSide)
end
rect rgba(245,230,255,0.8)
Note over Browser,Server: DataTables requests rows
Browser->>Server: AJAX GET /submissions.json (draw,start,length,search,order)
Server->>DB: Query submissions with filters/sort/limit (may compute score)
DB-->>Server: Return rows
Server->>Server: format_submission_for_datatable per row
Server-->>Browser: JSON (data, draw, recordsTotal, recordsFiltered)
Browser->>Browser: createdRow + drawCallback -> render row HTML, checkboxes, actions
end
rect rgba(230,255,235,0.8)
Note over User,Browser: Selection & batch actions
User->>Browser: Click row checkbox / select-all
Browser->>Browser: toggleRow / toggleAllRows -> update selections, UI highlight
Browser->>Browser: updateSelectedCount() -> enable/disable batch actions
end
Estimated code review effort
π― 4 (Complex) | β±οΈ ~45β75 minutes
- Focus review on:
-
app/controllers/submissions_controller.rb: search/sort correctness (especially computed-score sort), record counts, andformat_submission_for_datatabledata/HTML. -
app/assets/javascripts/manage_submissions.js: DataTablescolumnsmapping,createdRow/drawCallbackselection persistence, delegated event handlers, and batch-action endpoint wiring. - Column ordering and header β DataTables column index alignment in
app/views/submissions/index.html.erb.
-
Possibly related PRs
- autolab/Autolab#2248 β Overlaps same files and the move to DataTables/server-side loading and selection refactor.
- autolab/Autolab#2277 β Directly touches selection/count logic in
manage_submissions.js, overlapping selection behavior changes. - autolab/Autolab#2287 β Modifies select-all and per-row toggle and batch-action handling in
manage_submissions.js, closely related to this refactor.
Suggested reviewers
- KesterTan
- coder6583
- jhs-panda
Pre-merge checks and finishing touches
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
β Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | β Passed | The title "Manage submissions speed" clearly describes the main objective of the changesetβoptimizing the performance of the manage submissions page through server-side pagination. |
| Description check | β Passed | The description covers the key required sections: a clear summary of changes (server-side pagination implementation), motivation explaining the performance problem and its solution, and testing notes indicating local validation. |
β¨ Finishing touches
- [ ] π Generate docstrings
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
manage-submissions-speed
[!TIP]
π Customizable high-level summaries are now available in beta!
You can now customize how CodeRabbit generates the high-level summary in your pull requests β including its content, structure, tone, and formatting.
- Provide your own instructions using the
high_level_summary_instructionssetting.- Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
- Use
high_level_summary_in_walkthroughto move the summary from the description to the walkthrough section.Example instruction:
"Divide the high-level summary into five sections:
- π Description β Summarize the main change in 50β60 words, explaining what was done.
- π References β List relevant issues, discussions, documentation, or related PRs.
- π¦ Dependencies & Requirements β Mention any new/updated dependencies, environment variable changes, or configuration updates.
- π Contributor Summary β Include a Markdown table showing contributions:
| Contributor | Lines Added | Lines Removed | Files Changed |- βοΈ Additional Notes β Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Regrade all causes the whole page to re-render, the submissions seem to be empty for a while before it is loaded again.
As a result, the tooltip for regrade all also dissapears.
Regrade all causes the whole page to re-render, the submissions seem to be empty for a while before it is loaded again.
As a result, the tooltip for regrade all also dissapears.
The tooltip for regrade all does not disappear for me, was unable to reproduce this behavior
https://github.com/user-attachments/assets/e6e5faa1-5870-4fae-811d-523e969dff74
Check recording above, there should be a tooltip that says x number of submissions regraded but none is shown.