Refactor and unify annotation functions #1588
Labels
[C] Backend
Focuses on backend implementation
[P] Nice to have
Lowest priority. Some people might use this feature but it won't have a big impact.
[T] Refactoring
Existing parts should become faster, more readable, or in any other way better.
Currently we have these functions (feel free to add more if I missed any):
Evaluation:annotate_with_participant_and_voter_counts
: takesQuerySet
, uses a subquery and calls.annotate
, returns modifiedQuerySet
annotate_distributions_and_grades
: takes iterable of Evaluations, modifies in placeannotate_evaluations_with_grade_document_counts
: takesQuerySet
, calls.annotate
and returns modified QuerySetget_evaluations_with_course_result_attributes
: takes iterable of Evaluations, modifies and returns the same iterableresults.get_evaluations_with_prefetched_data
: takes iterable or QuerySet. Wrapper for 2 that will prefetch data if given aQuerySet
.staff.get_evaluations_with_prefetched_data
: Takes a semester, returnsQuerySet
annotated with a bunch of stuff, calls 1 and 3.get_evaluations_of_course
: Returns list, calls 4.Since I'm already at it, I'll also add here that
Semester
has two class methods:get_all_with_published_unarchived_results
get_all_with_unarchived_results
I think these functions should be refactored to use a uniform naming scheme. Maybe there are some possibilities for deduplication? Maybe we could always use QuerySets (perhaps not easily possible)?
The text was updated successfully, but these errors were encountered: