Skip to content
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

feat: create get_course_videos_qset API call #557

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions edxval/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,18 @@ def get_videos_for_course(course_id, sort_field=None, sort_dir=SortDirection.asc
)


def get_course_videos_qset(course_id):
"""
Get a QuerySet of CourseVideos for a given course.

This assumes that the caller can further filter as necessary.
"""
return CourseVideo.objects.select_related('video').filter(
course_id=str(course_id),
is_hidden=False,
)


def get_transcript_details_for_course(course_id):
"""
Get all the transcripts for a course and return details.
Expand Down
7 changes: 7 additions & 0 deletions edxval/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,13 @@ def test_get_video_ids_for_course_no_course_videos(self):

self.assertEqual(len(course_transcript), 0)

def test_get_course_videos_qset(self):
"""Test getting a minimal queryset."""
with self.assertNumQueries(1):
course_videos_qset = api.get_course_videos_qset(self.course_id)
course_video = course_videos_qset.get(video__edx_video_id="super-soaker")
self.assertEqual(course_video.video.client_video_id, "Shallow Swordfish")


@ddt
class GetYouTubeProfileVideosTest(TestCase):
Expand Down
Loading