-
Notifications
You must be signed in to change notification settings - Fork 246
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
Improved dashboard querying for TA data in overview graph #7420
base: master
Are you sure you want to change the base?
Conversation
… dashboard-query
Pull Request Test Coverage Report for Build 13381292272Details
💛 - Coveralls |
@@ -24,14 +24,25 @@ def get_groupings_by_assignment(assignment) | |||
.includes(:students, :tas, :group, :assignment) | |||
end | |||
|
|||
def marked_result_ids_for(assignment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So overall you have a good idea, but this should really be an assignment
method. This is because the true N+1 query is the fact that there's one query made per TA, and this method does not help address that problem.
You can instead write an assignment method that uses the same instance variable caching idea, but stores a hash mapping TA id to the two lists (what you currently call total_results
and marked_result_ids
). As a tip, you can first use pluck
to extract just the columns you want (ta id, result id, and marking state) and then Enumerable#group_by
.
Finally, you made a good comment about not wanting to change the behaviour of the existing assignment methods. What you can do is add to it an optional argument (say, bulk: false
) which, when true
, will run the query to get all TAs and set the instance attribute. But when it's false
you can default to just using the original code.
Finally, you should look closely at how Assignment#get_num_marked
currently works; it has a separate case for is_criteria_mark?
. This part has different logic for considering which results a TA has completed marking, based on the criteria the TA has been assigned rather than the result marking state.
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.)
Currently (especially with a large amount of graders), rendering the graphs in the dashboard view for an assignment is inefficient. This is due to a number of inefficient queries made obtaining completion counts.
def get_num_marked_from_cache(assignment)
def get_num_assigned_from_cache(assignment)
marked_result_ids_for(assignment)
function.get_num_marked
andget_num_assigned
methods. This reduces the number of queries made per TA.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.)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:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)
02/06/25: This is still WIP. Current "fix" is very shoddy.
02/09/25: Correctly uses assignment id to query data. Only one query is created to obtain all results associated with the TA.
02/17/25: Added testcases. One potential thing to note: The cached versions of the functions cannot be used interchangeably with their non-cached versions. This is the main reason why I added them to the ta class, to separate them to be for their very specific ta-defined usages.