Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions edxval/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,10 @@ def _get_video(edx_video_id):
"""
try:
encoded_videos = EncodedVideo.objects.select_related("profile")
course_videos = CourseVideo.objects.select_related("video_image")
return Video.objects \
.prefetch_related(Prefetch("encoded_videos", queryset=encoded_videos)) \
.prefetch_related("courses") \
.prefetch_related(Prefetch("courses", queryset=course_videos)) \
.get(edx_video_id=edx_video_id)
Comment on lines 542 to 547
except Video.DoesNotExist as no_video_error:
error_message = f"Video not found for edx_video_id: {edx_video_id}"
Expand Down Expand Up @@ -649,7 +650,12 @@ def _get_videos_for_filter(video_filter, sort_field=None, sort_dir=SortDirection
the given field and direction, with ties broken by edx_video_id to ensure a
total order.
"""
videos = Video.objects.filter(**video_filter)
video_image = CourseVideo.objects.select_related("video_image")
encoded_videos = EncodedVideo.objects.select_related("profile")
videos = Video.objects \
.prefetch_related(Prefetch("courses", queryset=video_image)) \
Comment on lines +653 to +656
.prefetch_related(Prefetch("encoded_videos", queryset=encoded_videos)) \
.filter(**video_filter)
Comment on lines +655 to +658
paginator_context = {}

if sort_field:
Expand Down
Loading