@@ -38,24 +38,22 @@ def create_course_notification_preferences_for_courses(self, course_ids):
3838 """
3939 This task creates Course Notification Preferences for users in courses.
4040 """
41- logger .info ('Running task create_course_notification_preferences' )
4241 newly_created = 0
4342 for course_id in course_ids :
4443 enrollments = CourseEnrollment .objects .filter (course_id = course_id , is_active = True )
45- logger .info (f'Found { enrollments .count ()} enrollments for course { course_id } ' )
46- logger .info (f'Creating Course Notification Preferences for course { course_id } ' )
44+ logger .debug (f'Found { enrollments .count ()} enrollments for course { course_id } ' )
45+ logger .debug (f'Creating Course Notification Preferences for course { course_id } ' )
4746 for enrollment in enrollments :
4847 _ , created = CourseNotificationPreference .objects .get_or_create (
4948 user = enrollment .user , course_id = course_id
5049 )
5150 if created :
5251 newly_created += 1
5352
54- logger .info (
53+ logger .debug (
5554 f'CourseNotificationPreference back-fill completed for course { course_id } .\n '
5655 f'Newly created course preferences: { newly_created } .\n '
5756 )
58- logger .info ('Completed task create_course_notification_preferences' )
5957
6058
6159@shared_task (ignore_result = True )
@@ -81,7 +79,6 @@ def delete_notifications(kwargs):
8179 )
8280 delete_count , _ = delete_queryset .delete ()
8381 total_deleted += delete_count
84- logger .info (f'Deleted in batch { delete_count } ' )
8582 logger .info (f'Total deleted: { total_deleted } ' )
8683
8784
@@ -93,7 +90,6 @@ def delete_expired_notifications():
9390 """
9491 batch_size = settings .EXPIRED_NOTIFICATIONS_DELETE_BATCH_SIZE
9592 expiry_date = datetime .now (UTC ) - timedelta (days = settings .NOTIFICATIONS_EXPIRY )
96- logger .info (f'Deleting expired notifications with batch size: { batch_size } ' )
9793 start_time = datetime .now ()
9894 total_deleted = 0
9995 delete_count = None
@@ -109,7 +105,6 @@ def delete_expired_notifications():
109105 delete_count , _ = delete_queryset .delete ()
110106 total_deleted += delete_count
111107 time_elapsed = datetime .now () - batch_start_time
112- logger .info (f'{ delete_count } Notifications deleted in current batch in { time_elapsed } seconds.' )
113108 time_elapsed = datetime .now () - start_time
114109 logger .info (f'{ total_deleted } Notifications deleted in { time_elapsed } seconds.' )
115110
@@ -137,9 +132,9 @@ def send_notifications(user_ids, course_key: str, app_name, notification_type, c
137132 generated_notification_audience = []
138133
139134 for batch_user_ids in get_list_in_batches (user_ids , batch_size ):
140- logger .info (f'Sending notifications to { len (batch_user_ids )} users in { course_key } ' )
135+ logger .debug (f'Sending notifications to { len (batch_user_ids )} users in { course_key } ' )
141136 batch_user_ids = NotificationFilter ().apply_filters (batch_user_ids , course_key , notification_type )
142- logger .info (f'After applying filters, sending notifications to { len (batch_user_ids )} users in { course_key } ' )
137+ logger .debug (f'After applying filters, sending notifications to { len (batch_user_ids )} users in { course_key } ' )
143138
144139 # check if what is preferences of user and make decision to send notification or not
145140 preferences = CourseNotificationPreference .objects .filter (
@@ -186,8 +181,6 @@ def send_notifications(user_ids, course_key: str, app_name, notification_type, c
186181 notification_content = notification_objects [0 ].content
187182
188183 if notifications_generated :
189- logger .info (f'Temp: Notifications generated for { len (generated_notification_audience )} out of '
190- f'{ len (user_ids )} users - { app_name } - { notification_type } - { course_key } .' )
191184 notification_generated_event (
192185 generated_notification_audience , app_name , notification_type , course_key , content_url ,
193186 notification_content , sender_id = sender_id
@@ -227,7 +220,6 @@ def create_notification_pref_if_not_exists(user_ids: List, preferences: List, co
227220 user_id = user_id ,
228221 course_id = course_id ,
229222 ))
230- logger .info ('Creating new notification preference for user because it does not exist.' )
231223 if new_preferences :
232224 # ignoring conflicts because it is possible that preference is already created by another process
233225 # conflicts may arise because of constraint on user_id and course_id fields in model
0 commit comments