Commit 9a87cb61 by Dennis Jen

Merge pull request #74 from edx/dsjen/update-view-fields

Updated video endpoints to return users_at_start and users_at_end.
parents 2874784f 4a6d18d2
...@@ -174,11 +174,11 @@ class Command(BaseCommand): ...@@ -174,11 +174,11 @@ class Command(BaseCommand):
models.Video.objects.all().delete() models.Video.objects.all().delete()
logger.info("Generating new course videos...") logger.info("Generating new course videos...")
start_views = 1234 users_at_start = 1234
models.Video.objects.create(course_id=course_id, pipeline_video_id=video_id, models.Video.objects.create(course_id=course_id, pipeline_video_id=video_id,
encoded_module_id=module_id, duration=500, segment_length=5, encoded_module_id=module_id, duration=500, segment_length=5,
start_views=start_views, users_at_start=users_at_start,
end_views=random.randint(100, start_views)) users_at_end=random.randint(100, users_at_start))
def handle(self, *args, **options): def handle(self, *args, **options):
course_id = 'edX/DemoX/Demo_Course' course_id = 'edX/DemoX/Demo_Course'
......
...@@ -200,8 +200,8 @@ class Video(BaseVideo): ...@@ -200,8 +200,8 @@ class Video(BaseVideo):
encoded_module_id = models.CharField(db_index=True, max_length=255) encoded_module_id = models.CharField(db_index=True, max_length=255)
duration = models.IntegerField() duration = models.IntegerField()
segment_length = models.IntegerField() segment_length = models.IntegerField()
start_views = models.IntegerField() users_at_start = models.IntegerField()
end_views = models.IntegerField() users_at_end = models.IntegerField()
class Meta(BaseVideo.Meta): class Meta(BaseVideo.Meta):
db_table = 'video' db_table = 'video'
...@@ -289,8 +289,8 @@ class VideoSerializer(ModelSerializerWithCreatedField): ...@@ -289,8 +289,8 @@ class VideoSerializer(ModelSerializerWithCreatedField):
'encoded_module_id', 'encoded_module_id',
'duration', 'duration',
'segment_length', 'segment_length',
'start_views', 'users_at_start',
'end_views', 'users_at_end',
'created' 'created'
) )
......
...@@ -661,14 +661,14 @@ class CourseVideosListViewTests(DemoCourseMixin, TestCaseWithAuthentication): ...@@ -661,14 +661,14 @@ class CourseVideosListViewTests(DemoCourseMixin, TestCaseWithAuthentication):
created = datetime.datetime.utcnow() created = datetime.datetime.utcnow()
date_time_format = '%Y-%m-%d %H:%M:%S' date_time_format = '%Y-%m-%d %H:%M:%S'
G(models.Video, course_id=self.course_id, encoded_module_id=module_id, G(models.Video, course_id=self.course_id, encoded_module_id=module_id,
pipeline_video_id=video_id, duration=100, segment_length=1, start_views=50, end_views=10, pipeline_video_id=video_id, duration=100, segment_length=1, users_at_start=50, users_at_end=10,
created=created.strftime(date_time_format)) created=created.strftime(date_time_format))
alt_module_id = 'i4x-test-video-2' alt_module_id = 'i4x-test-video-2'
alt_video_id = 'a1d30' alt_video_id = 'a1d30'
alt_created = created + datetime.timedelta(seconds=10) alt_created = created + datetime.timedelta(seconds=10)
G(models.Video, course_id=self.course_id, encoded_module_id=alt_module_id, G(models.Video, course_id=self.course_id, encoded_module_id=alt_module_id,
pipeline_video_id=alt_video_id, duration=200, segment_length=5, start_views=1050, end_views=50, pipeline_video_id=alt_video_id, duration=200, segment_length=5, users_at_start=1050, users_at_end=50,
created=alt_created.strftime(date_time_format)) created=alt_created.strftime(date_time_format))
expected = [ expected = [
...@@ -677,8 +677,8 @@ class CourseVideosListViewTests(DemoCourseMixin, TestCaseWithAuthentication): ...@@ -677,8 +677,8 @@ class CourseVideosListViewTests(DemoCourseMixin, TestCaseWithAuthentication):
'encoded_module_id': module_id, 'encoded_module_id': module_id,
'pipeline_video_id': video_id, 'pipeline_video_id': video_id,
'segment_length': 1, 'segment_length': 1,
'start_views': 50, 'users_at_start': 50,
'end_views': 10, 'users_at_end': 10,
'created': created.strftime(settings.DATETIME_FORMAT) 'created': created.strftime(settings.DATETIME_FORMAT)
}, },
{ {
...@@ -686,8 +686,8 @@ class CourseVideosListViewTests(DemoCourseMixin, TestCaseWithAuthentication): ...@@ -686,8 +686,8 @@ class CourseVideosListViewTests(DemoCourseMixin, TestCaseWithAuthentication):
'encoded_module_id': alt_module_id, 'encoded_module_id': alt_module_id,
'pipeline_video_id': alt_video_id, 'pipeline_video_id': alt_video_id,
'segment_length': 5, 'segment_length': 5,
'start_views': 1050, 'users_at_start': 1050,
'end_views': 50, 'users_at_end': 50,
'created': alt_created.strftime(settings.DATETIME_FORMAT) 'created': alt_created.strftime(settings.DATETIME_FORMAT)
} }
] ]
......
...@@ -695,8 +695,8 @@ class VideosListView(BaseCourseView): ...@@ -695,8 +695,8 @@ class VideosListView(BaseCourseView):
* encoded_module_id: The encoded module ID. * encoded_module_id: The encoded module ID.
* duration: The length of the video in seconds. * duration: The length of the video in seconds.
* segment_length: The length of each segment of the video in seconds. * segment_length: The length of each segment of the video in seconds.
* start_views: The number of views at the start of the video. * users_at_start: The number of viewers at the start of the video.
* end_views: The number of views at the end of the video. * users_at_end: The number of viewers at the end of the video.
* created: The date the video data was updated. * created: The date the video data was updated.
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment