Skip to content

Commit

Permalink
feat: send datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
rayzhou-bit committed Dec 16, 2024
1 parent 3f82c62 commit 30a0765
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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 {})
}
Expand Down

0 comments on commit 30a0765

Please sign in to comment.