Skip to content

Commit

Permalink
feat: apply removable annotations on applicable querysets
Browse files Browse the repository at this point in the history
  • Loading branch information
shadinaif committed Nov 16, 2024
1 parent 370d68b commit c8817d2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions futurex_openedx_extensions/dashboard/details/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
check_staff_exist_queryset,
get_base_queryset_courses,
get_one_user_queryset,
update_removable_annotations,
)


Expand Down Expand Up @@ -62,6 +63,8 @@ def annotate_courses_rating_queryset(
), 0),
)

update_removable_annotations(queryset, removable=['rating_count', 'rating_total'])

return queryset


Expand Down Expand Up @@ -144,6 +147,10 @@ def get_courses_queryset(
)
)

update_removable_annotations(queryset, removable=[
'enrolled_count', 'active_count', 'certificates_count', 'completion_rate',
])

return queryset


Expand Down Expand Up @@ -216,4 +223,6 @@ def get_learner_courses_info_queryset(
)
)

update_removable_annotations(queryset, removable=['related_user_id', 'enrollment_date', 'last_activity'])

return queryset
7 changes: 7 additions & 0 deletions futurex_openedx_extensions/dashboard/details/learners.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
get_learners_search_queryset,
get_one_user_queryset,
get_permitted_learners_queryset,
update_removable_annotations,
)


Expand Down Expand Up @@ -141,6 +142,8 @@ def get_learners_queryset(
)
).select_related('profile', 'extrainfo').order_by('id')

update_removable_annotations(queryset, removable=['courses_count', 'certificates_count'])

return queryset


Expand Down Expand Up @@ -202,6 +205,8 @@ def get_learners_by_course_queryset(
)
).select_related('profile').order_by('id')

update_removable_annotations(queryset, removable=['certificate_available', 'course_score', 'active_in_course'])

return queryset


Expand Down Expand Up @@ -249,4 +254,6 @@ def get_learner_info_queryset(
)
).select_related('profile')

update_removable_annotations(queryset, removable=['courses_count', 'certificates_count'])

return queryset
4 changes: 4 additions & 0 deletions futurex_openedx_extensions/helpers/querysets.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,15 @@ def get_base_queryset_courses(
),
)

update_removable_annotations(q_set, removable=['course_is_active', 'course_is_visible'])

if active_filter is not None:
q_set = q_set.filter(course_is_active=active_filter)
update_removable_annotations(q_set, not_removable=['course_is_active'])

if visible_filter is not None:
q_set = q_set.filter(course_is_visible=visible_filter)
update_removable_annotations(q_set, not_removable=['course_is_visible'])

return q_set

Expand Down

0 comments on commit c8817d2

Please sign in to comment.