perf(AssessmentStatistics): add lazyloading for Statistics page data #7976
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.
Problem
The
/main_statistics
route at theassessments#main_statistics
fetches all statistics-related data at once. This includes:Note: Live feedback data has already been separated.
This design results in unnecessary data fetching, especially when users visit tabs that do not require certain datasets.
Changes
We’ve separated the following data concerns into individual endpoints:
/assessment_statistics
/submission_statistics
/ancestor_info
This allows for on-demand fetching, triggered only when the user navigates to the tab that needs the corresponding data.
Tab-to-Data Mapping
Below is the breakdown of which data each tab requires:
StudentGradesPerQuestionTable
StudentAttemptCountTable
MainGradesChart
MainSubmissionTimeAndGradeStatistics
DuplicationHistoryStatistics
LiveFeedbackStatistics
Each tab first checks the Redux store for cached data and fetches only if necessary.
Design Considerations
While we considered reusing existing endpoints (
submissions#index
,assessments#show
), we opted to split out dedicated statistics endpoints for the following reasons:Course::Statistics::AssessmentsController
uses.unscope
to bypass default scopes, which could introduce side effects if added to#show
.includes(programming_questions: [:language])
).Course::Assessment::AssessmentsController
has concerns for assessment management and external service integration, whileCourse::Statistics::AssessmentsController
has concerns that handle data aggregation.