Improve Dolos Hub usability - #124
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the usability and responsiveness of the Dolos Hub by decoupling the hub page render from potentially slow report generation, while also introducing several performance optimizations in submission selection and dataset/report generation.
Changes:
- Make
dolos_hubrender immediately and trigger report generation via a new JSON endpoint (dolos_hub_report) to keep the navigation usable during long-running report generation. - Optimize DB access patterns for submissions (e.g.,
select_related, correlated subquery for best submissions) to reduce query count and improve scalability. - Speed up Dolos dataset creation by fetching submission texts concurrently and reusing an HTTP client/session for connection pooling.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| review/views.py | Splits hub rendering from report generation; adds scope helper and JSON report-status endpoint. |
| review/urls.py | Adds routes for the new dolos_hub_report AJAX/JSON endpoints (course + exercise scopes). |
| review/templates/review/dolos_hub.html | Adds loading UI and client-side fetch to transition from “generating” state to embedded report iframe. |
| review/dolos_reports.py | Parallelizes get_text calls to reduce end-to-end report build time. |
| provider/aplus.py | Reuses a shared AplusTokenClient/Session with a larger connection pool to support concurrent fetches. |
| data/models.py | Reimplements Exercise.best_submissions using a correlated subquery to avoid O(n) per-student queries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+914
to
+916
| selected_count = sum( | ||
| _exercise_submissions(ex, include_all).count() for ex in course.exercises.all() | ||
| ) |
Comment on lines
+95
to
+106
| global _api_client | ||
| if _api_client is None: | ||
| client = AplusTokenClient(settings.APLUS_ROBOT_TOKEN) | ||
| # Default adapter pool (10 connections) is too small once several | ||
| # submissions are fetched concurrently (see review/dolos_reports.py's | ||
| # ThreadPoolExecutor); size it generously so threads reuse connections | ||
| # instead of opening new ones or blocking for a free slot. | ||
| adapter = requests.adapters.HTTPAdapter(pool_connections=32, pool_maxsize=32) | ||
| client.session.mount("https://", adapter) | ||
| client.session.mount("http://", adapter) | ||
| _api_client = client | ||
| return _api_client |
| ``label_fn(submission)`` returns the Dolos colour label and | ||
| ``get_text(submission)`` returns the source code. Returns the info rows. | ||
| """ | ||
| submissions = list(submissions) |
Comment on lines
+44
to
+46
| fetch("{{ report_status_url|escapejs }}", { headers: { "X-Requested-With": "XMLHttpRequest" } }) | ||
| .then(function (response) { return response.json(); }) | ||
| .then(function (data) { |
Comment on lines
+925
to
+929
| """ | ||
| AJAX endpoint backing dolos_hub's loading indicator: does the actual | ||
| (potentially slow) submission gathering + report generation/upload, and | ||
| reports back whether a report is ready, empty, or failed. | ||
| """ |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
What?
[ANSWER HERE]
Why?
[ANSWER HERE]
How?
[ANSWER HERE]
Fixes #
Testing
Remember to add or update unit tests for new features and changes.
What type of test did you run?
[ADD A DESCRIPTION ABOUT WHAT YOU TESTED MANUALLY]
Did you test the changes in
Think of what is affected by these changes and could become broken
Translation
Programming style
Have you updated the README or other relevant documentation?
Is it Done?
Clean up your git commit history before submitting the pull request!