Add batching support
This commit is contained in:
@@ -12,7 +12,7 @@ from openedx.core.djangoapps.video_config.forms import (
|
||||
from openedx.core.djangoapps.video_config.models import (
|
||||
CourseHLSPlaybackEnabledFlag, HLSPlaybackEnabledFlag,
|
||||
CourseVideoTranscriptEnabledFlag, VideoTranscriptEnabledFlag,
|
||||
TranscriptMigrationSetting,
|
||||
TranscriptMigrationSetting, MigrationEnqueuedCourse,
|
||||
)
|
||||
|
||||
|
||||
@@ -49,9 +49,23 @@ class CourseVideoTranscriptEnabledFlagAdmin(CourseSpecificEnabledFlagBaseAdmin):
|
||||
"""
|
||||
form = CourseVideoTranscriptFlagAdminForm
|
||||
|
||||
|
||||
class MigrationEnqueuedCourseAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
Simple, read-only list/search view of the Courses whose transcripts have been migrated to S3.
|
||||
"""
|
||||
list_display = [
|
||||
'course_id',
|
||||
'command_run',
|
||||
]
|
||||
|
||||
search_fields = ['course_id', 'command_run']
|
||||
|
||||
|
||||
admin.site.register(HLSPlaybackEnabledFlag, ConfigurationModelAdmin)
|
||||
admin.site.register(CourseHLSPlaybackEnabledFlag, CourseHLSPlaybackEnabledFlagAdmin)
|
||||
|
||||
admin.site.register(VideoTranscriptEnabledFlag, ConfigurationModelAdmin)
|
||||
admin.site.register(CourseVideoTranscriptEnabledFlag, CourseVideoTranscriptEnabledFlagAdmin)
|
||||
admin.site.register(TranscriptMigrationSetting, ConfigurationModelAdmin)
|
||||
admin.site.register(MigrationEnqueuedCourse, MigrationEnqueuedCourseAdmin)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.14 on 2018-07-19 07:52
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
import model_utils.fields
|
||||
import opaque_keys.edx.django.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('video_config', '0004_transcriptmigrationsetting_command_run'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='MigrationEnqueuedCourse',
|
||||
fields=[
|
||||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
|
||||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
|
||||
('course_id', opaque_keys.edx.django.models.CourseKeyField(db_index=True, max_length=255, primary_key=True, serialize=False)),
|
||||
('command_run', models.PositiveIntegerField(default=0)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='transcriptmigrationsetting',
|
||||
name='batch_size',
|
||||
field=models.PositiveIntegerField(default=0),
|
||||
),
|
||||
]
|
||||
@@ -1,8 +1,10 @@
|
||||
"""
|
||||
Configuration models for Video XModule
|
||||
"""
|
||||
from config_models.models import ConfigurationModel
|
||||
from django.db.models import BooleanField, TextField, PositiveIntegerField
|
||||
|
||||
from config_models.models import ConfigurationModel
|
||||
from model_utils.models import TimeStampedModel
|
||||
from opaque_keys.edx.django.models import CourseKeyField
|
||||
|
||||
|
||||
@@ -150,6 +152,7 @@ class TranscriptMigrationSetting(ConfigurationModel):
|
||||
help_text="Flag to force migrate transcripts for the requested courses, overwrite if already present."
|
||||
)
|
||||
command_run = PositiveIntegerField(default=0)
|
||||
batch_size = PositiveIntegerField(default=0)
|
||||
commit = BooleanField(
|
||||
default=False,
|
||||
help_text="Dry-run or commit."
|
||||
@@ -170,3 +173,16 @@ class TranscriptMigrationSetting(ConfigurationModel):
|
||||
self.command_run += 1
|
||||
self.save()
|
||||
return self.command_run
|
||||
|
||||
|
||||
class MigrationEnqueuedCourse(TimeStampedModel):
|
||||
"""
|
||||
Temporary model to persist the course IDs who has been enqueued for transcripts migration to S3.
|
||||
"""
|
||||
course_id = CourseKeyField(db_index=True, primary_key=True, max_length=255)
|
||||
command_run = PositiveIntegerField(default=0)
|
||||
|
||||
def __unicode__(self):
|
||||
return u'MigrationEnqueuedCourse: ID={course_id}, Run={command_run}'.format(
|
||||
course_id=self.course_id, command_run=self.command_run
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user