From 9c392ea7de500a0dde621c433bc4751059605143 Mon Sep 17 00:00:00 2001 From: zawan-ila <87228907+zawan-ila@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:17:23 +0500 Subject: [PATCH] fix: race condition in analytics loader (#4498) --- .../apps/course_metadata/data_loaders/analytics_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/course_discovery/apps/course_metadata/data_loaders/analytics_api.py b/course_discovery/apps/course_metadata/data_loaders/analytics_api.py index 03ae6efee2..4b9cd83b79 100644 --- a/course_discovery/apps/course_metadata/data_loaders/analytics_api.py +++ b/course_discovery/apps/course_metadata/data_loaders/analytics_api.py @@ -58,7 +58,7 @@ def ingest(self): program = program_dict['program'] program.enrollment_count = program_dict['count'] program.recent_enrollment_count = program_dict['recent_count'] - program.save(suppress_publication=True) + program.save(update_fields=['enrollment_count', 'recent_enrollment_count'], suppress_publication=True) logger.info('Updating program: %s', program.uuid) def _process_course_run_summary(self, course_run_summary): @@ -76,7 +76,7 @@ def _process_course_run_summary(self, course_run_summary): # Update course run counts course_run.enrollment_count = course_run_count course_run.recent_enrollment_count = course_run_recent_count - course_run.save(suppress_publication=True) + course_run.save(update_fields=['enrollment_count', 'recent_enrollment_count'], suppress_publication=True) # Add course run total to course total in dictionary if course.uuid in self.course_dictionary: