Skip to content

perf(AssessmentStatistics): add lazyloading for Statistics page data #7976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

craigtonlian
Copy link
Contributor

@craigtonlian craigtonlian commented Jun 9, 2025

Problem

The /main_statistics route at the assessments#main_statistics fetches all statistics-related data at once. This includes:

  • Assessment statistics
  • Submission statistics
  • Ancestor info

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:

Tab Required Data
StudentGradesPerQuestionTable Assessment, Submissions
StudentAttemptCountTable Assessment, Submissions
MainGradesChart Submissions
MainSubmissionTimeAndGradeStatistics Submissions
DuplicationHistoryStatistics Ancestor
LiveFeedbackStatistics Assessment, Live Feedback

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.
  • Specific associations are required for statistics (e.g. includes(programming_questions: [:language])).
  • Keeps controllers lean and prevents unnecessary data loading in CRUD endpoints.
  • Course::Assessment::AssessmentsController has concerns for assessment management and external service integration, while Course::Statistics::AssessmentsController has concerns that handle data aggregation.

@craigtonlian craigtonlian force-pushed the craigtonlian/add_statistics_lazyload branch 5 times, most recently from fb23f6c to dbd2309 Compare June 9, 2025 03:41
@craigtonlian craigtonlian force-pushed the craigtonlian/add_statistics_lazyload branch from dbd2309 to 1ec351e Compare June 9, 2025 06:33
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.

1 participant