Skip to content

Commit 58dd7f6

Browse files
authored
Fix use of log warning of added courses by creating separate string ID list (#1476) (#1477)
* Prepare and use separate list of string IDs * Make valid_locked_course_ids list[str], add a few types; downgrade log to debug
1 parent b386139 commit 58dd7f6

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

dashboard/cron.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class DashboardCronJob(CronJobBase):
115115
def __init__(self) -> None:
116116
"""Constructor to be used to declare valid_locked_course_ids instance variable."""
117117
super().__init__()
118-
self.valid_locked_course_ids: List[int]
118+
self.valid_locked_course_ids: List[str]
119119

120120
# verify whether course ids are valid
121121
def verify_course_ids(self):
@@ -447,7 +447,7 @@ def update_groups(self):
447447
# loop through multiple course ids
448448
status += util_function(queries['assignment_groups'],
449449
'assignment_groups',
450-
{'course_ids':tuple(self.valid_locked_course_ids)})
450+
{'course_ids': tuple(self.valid_locked_course_ids)})
451451

452452
return status
453453

@@ -463,7 +463,7 @@ def update_assignment(self):
463463
# loop through multiple course ids
464464
status += util_function(queries['assignment'],
465465
'assignment',
466-
{'course_ids':tuple(self.valid_locked_course_ids)})
466+
{'course_ids': tuple(self.valid_locked_course_ids)})
467467

468468
return status
469469

@@ -482,7 +482,7 @@ def submission(self):
482482
status += util_function(queries['submission'],
483483
'submission',
484484
{
485-
'course_ids':tuple(self.valid_locked_course_ids),
485+
'course_ids': tuple(self.valid_locked_course_ids),
486486
'canvas_data_id_increment': settings.CANVAS_DATA_ID_INCREMENT
487487
})
488488

@@ -501,7 +501,7 @@ def weight_consideration(self):
501501
# loop through multiple course ids
502502
status += util_function(queries['assignment_weight'],
503503
'assignment_weight_consideration',
504-
{'course_ids':tuple(self.valid_locked_course_ids)},
504+
{'course_ids': tuple(self.valid_locked_course_ids)},
505505
'weight')
506506

507507
logger.debug(status + "\n\n")
@@ -581,7 +581,7 @@ def update_course(self, warehouse_courses_data: pd.DataFrame) -> str:
581581
status += f'Course {course.id}: updated {", ".join(updated_fields)}\n'
582582
return status
583583

584-
def do(self):
584+
def do(self) -> str:
585585
logger.info("** MyLA cron tab")
586586

587587
status = ""
@@ -595,7 +595,7 @@ def do(self):
595595
status += f"ERROR: Those course ids are invalid: {invalid_course_id_list}\n"
596596
status += "End cron: " + str(datetime.now()) + "\n"
597597
logger.info("************ total status=" + status + "/n/n")
598-
return (status,)
598+
return status
599599

600600
# Lock in valid course IDs that data will be pulled for.
601601
self.valid_locked_course_ids = [str(x) for x in course_verification.course_data['id'].to_list()]
@@ -639,12 +639,14 @@ def do(self):
639639
logger.info("** informational")
640640
status += self.update_unizin_metadata()
641641

642-
courses_added_during_cron: List[int] = list(
643-
set(Course.objects.get_supported_courses().values_list('id', flat=True)) - set(self.valid_locked_course_ids))
642+
all_str_course_ids = set(
643+
str(x) for x in Course.objects.get_supported_courses().values_list('id', flat=True)
644+
)
645+
courses_added_during_cron: List[str] = list(all_str_course_ids - set(self.valid_locked_course_ids))
644646
if courses_added_during_cron:
645-
logger.warning(
647+
logger.debug(
646648
f'During the run, users added {len(courses_added_during_cron)} course(s): {courses_added_during_cron}')
647-
logger.warning(f'No data was pulled for these courses.')
649+
logger.debug(f'No data was pulled for these courses.')
648650

649651
# Set all of the courses to have been updated now (this is the same set update_course runs on)
650652
if not exception_in_run:

0 commit comments

Comments
 (0)