From f86e02a8d304205e7d541882203555d948589cfe Mon Sep 17 00:00:00 2001
From: rayzhou-bit <rzhou@2u.com>
Date: Wed, 15 Jan 2025 21:56:55 +0000
Subject: [PATCH] fix: created at none case

---
 .../rest_api/v0/views/course_optimizer.py     | 37 +------------------
 1 file changed, 1 insertion(+), 36 deletions(-)

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 abbc9c2e87cb..82e43d629a87 100644
--- a/cms/djangoapps/contentstore/rest_api/v0/views/course_optimizer.py
+++ b/cms/djangoapps/contentstore/rest_api/v0/views/course_optimizer.py
@@ -183,44 +183,9 @@ def get(self, request: Request, course_id: str):
                         # Wasn't JSON, just use the value as a string
                         pass
 
-        # print('DTO')
-        # print(broken_links_dto)
-
-        # mock dto for testing
-        # broken_links_dto = {
-        #     'sections': [
-        #         {
-        #             'id': 'sectid',
-        #             'displayName': 'sectname',
-        #             'subsections': [
-        #                 {
-        #                     'id': 'subid',
-        #                     'displayName': 'subname',
-        #                     'units': [
-        #                         {
-        #                             'id': 'unitid',
-        #                             'displayName': 'unitname',
-        #                             'blocks': [
-        #                                 {
-        #                                     'id': 'blockid',
-        #                                     'displayName': 'blockname',
-        #                                     'url': 'blockurl',
-        #                                     'brokenLinks': [
-        #                                         'link1',
-        #                                         'link2',
-        #                                     ],
-        #                                 },
-        #                             ],
-        #                         }
-        #                     ]
-        #                 }
-        #             ]
-        #         }
-        #     ]
-        # }
         data = {
             'LinkCheckStatus': status,
-            'LinkCheckCreatedAt': created_at,
+            **({'LinkCheckCreatedAt': created_at} if created_at else {}),
             **({'LinkCheckOutput': broken_links_dto} if broken_links_dto else {}),
             **({'LinkCheckError': error} if error else {})
         }