diff --git a/cms/djangoapps/contentstore/rest_api/v0/serializers/course_optimizer.py b/cms/djangoapps/contentstore/rest_api/v0/serializers/course_optimizer.py index 50a8d6e5310b..fa78b4710ff4 100644 --- a/cms/djangoapps/contentstore/rest_api/v0/serializers/course_optimizer.py +++ b/cms/djangoapps/contentstore/rest_api/v0/serializers/course_optimizer.py @@ -38,4 +38,5 @@ class LinkCheckOutputSerializer(serializers.Serializer): class LinkCheckSerializer(serializers.Serializer): """ Serializer for broken links """ LinkCheckStatus = serializers.CharField(required=True) + LinkCheckCreatedAt = serializers.DateTimeField(required=False) LinkCheckOutput = LinkCheckOutputSerializer(required=True) diff --git a/cms/djangoapps/contentstore/rest_api/v0/views/course_optimizer.py b/cms/djangoapps/contentstore/rest_api/v0/views/course_optimizer.py index a72c3407e28d..abbc9c2e87cb 100644 --- a/cms/djangoapps/contentstore/rest_api/v0/views/course_optimizer.py +++ b/cms/djangoapps/contentstore/rest_api/v0/views/course_optimizer.py @@ -154,6 +154,7 @@ def get(self, request: Request, course_id: str): task_status = _latest_task_status(request, course_id) status = None + created_at = None broken_links_dto = None error = None if task_status is None: @@ -165,6 +166,7 @@ def get(self, request: Request, course_id: str): status = 'Uninitiated' else: status = task_status.state + created_at = task_status.created if task_status.state == UserTaskStatus.SUCCEEDED: artifact = UserTaskArtifact.objects.get(status=task_status, name='BrokenLinks') with artifact.file as file: @@ -218,6 +220,7 @@ def get(self, request: Request, course_id: str): # } data = { 'LinkCheckStatus': status, + 'LinkCheckCreatedAt': created_at, **({'LinkCheckOutput': broken_links_dto} if broken_links_dto else {}), **({'LinkCheckError': error} if error else {}) }