Skip to content

Commit

Permalink
Merge pull request #167 from edx/mrehan/fix-long-query-string
Browse files Browse the repository at this point in the history
Missing HLS profile view accepts unlimited course IDs
  • Loading branch information
Qubad786 authored Jan 9, 2019
2 parents bfc48ea + ed261c6 commit 9f9994b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
10 changes: 4 additions & 6 deletions edxval/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,7 @@ def test_videos_list_missing_hls_encodes(self, batch_size, offset):
Test that videos that are missing HLS encodes are returned correctly.
"""
expected_video_ids = ['video-wo-hls1', 'video-wo-hls2']
endpoint = urljoin(self.url, '?{}'.format(urlencode({'batch_size': batch_size, 'offset': offset})))
response = self.client.get(endpoint)
response = self.client.post(self.url, {'batch_size': batch_size, 'offset': offset}, format='json')
response = json.loads(response.content)
self.assertEqual(response['videos'], expected_video_ids[offset: offset+batch_size])

Expand All @@ -1015,10 +1014,9 @@ def test_videos_list_missing_hls_encodes_for_courses(self):
Test that videos that are missing HLS encodes are returned correctly for the specified courses.
"""
expected_video_ids = ['video-wo-hls1']
endpoint = urljoin(self.url, '?{}'.format(urlencode({
response = self.client.post(self.url, {
'courses': ['test-course-1', 'test-course-2']
}, True)))
response = self.client.get(endpoint)
}, format='json')
response = json.loads(response.content)
self.assertEqual(response['videos'], expected_video_ids)

Expand All @@ -1035,7 +1033,7 @@ def test_update_hls_encodes_for_video(self):
'url': 'foo.com/abcd.m3u8'
}
}
response = self.client.post(self.url, expected_data, format='json')
response = self.client.put(self.url, expected_data, format='json')
# Assert the success response.
self.assertEqual(response.status_code, 200)

Expand Down
41 changes: 36 additions & 5 deletions edxval/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,41 @@ class HLSMissingVideoView(APIView):
"""
authentication_classes = (OAuth2Authentication, SessionAuthentication)

def get(self, request):
courses = request.query_params.getlist('courses')
batch_size = int(request.query_params.get('batch_size', 50))
offset = int(request.query_params.get('offset', 0))
def post(self, request):
"""
Retrieve video IDs that are missing HLS profiles. This endpoint supports 2 types of input data:
1. If we want a batch of video ids which are missing HLS profile irrespective of their courses, the request
data should be in following format:
{
'batch_size': 50,
'offset': 0
}
And response will be in following format:
{
'videos': ['video_id1', 'video_id2', 'video_id3', ... , video_id50],
'total': 300,
'offset': 50,
'batch_size': 50
}
2. If we want all the videos which are missing HLS profiles in a set of specific courses, the request data
should be in following format:
{
'courses': [
'course_id1',
'course_id2',
...
]
}
And response will be in following format:
{
'videos': ['video_id1', 'video_id2', 'video_id3', ...]
}
"""
courses = request.data.get('courses')
batch_size = request.data.get('batch_size', 50)
offset = request.data.get('offset', 0)
if courses:
videos = (CourseVideo.objects.select_related('video')
.prefetch_related('video__encoded_videos', 'video__encoded_videos__profile')
Expand Down Expand Up @@ -301,7 +332,7 @@ def get(self, request):

return response

def post(self, request):
def put(self, request):
"""
Update a single profile for a given video.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def load_requirements(*requirements_paths):
return list(requirements)


VERSION = '0.1.25'
VERSION = '1.1.25'

if sys.argv[-1] == 'tag':
print("Tagging the version on github:")
Expand Down

0 comments on commit 9f9994b

Please sign in to comment.