Skip to content

Commit cc62389

Browse files
fix: updated info logs to debug (#35050)
1 parent 06264e7 commit cc62389

2 files changed

Lines changed: 14 additions & 21 deletions

File tree

openedx/core/djangoapps/notifications/filters.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def filter_audit_expired_users_with_no_role(self, user_ids, course) -> list:
6464
access_duration = get_expected_duration(course.id)
6565
course_time_limit = CourseDurationLimitConfig.current(course_key=course.id)
6666
if not verified_mode:
67-
logger.info(
67+
logger.debug(
6868
"NotificationFilter: Course %s does not have a verified mode, so no users will be filtered out",
6969
course.id,
7070
)
@@ -81,11 +81,12 @@ def filter_audit_expired_users_with_no_role(self, user_ids, course) -> list:
8181

8282
if course_time_limit.enabled_for_course(course.id):
8383
enrollments = enrollments.filter(created__gte=course_time_limit.enabled_as_of)
84-
logger.info("NotificationFilter: Number of audit enrollments for course %s: %s", course.id, enrollments.count())
84+
logger.debug("NotificationFilter: Number of audit enrollments for course %s: %s", course.id,
85+
enrollments.count())
8586

8687
for enrollment in enrollments:
8788
if enrollment.user_id in users_with_course_role or enrollment.user_id in users_with_forum_roles:
88-
logger.info(
89+
logger.debug(
8990
"NotificationFilter: User %s has a course or forum role for course %s, so they will not be "
9091
"filtered out",
9192
enrollment.user_id,
@@ -94,11 +95,11 @@ def filter_audit_expired_users_with_no_role(self, user_ids, course) -> list:
9495
continue
9596
content_availability_date = max(enrollment.created, course.start)
9697
expiration_date = content_availability_date + access_duration
97-
logger.info("NotificationFilter: content_availability_date: %s and access_duration: %s",
98-
content_availability_date, access_duration
99-
)
98+
logger.debug("NotificationFilter: content_availability_date: %s and access_duration: %s",
99+
content_availability_date, access_duration
100+
)
100101
if expiration_date and timezone.now() > expiration_date:
101-
logger.info("User %s has expired audit access to course %s", enrollment.user_id, course.id)
102+
logger.debug("User %s has expired audit access to course %s", enrollment.user_id, course.id)
102103
user_ids.remove(enrollment.user_id)
103104
return user_ids
104105

@@ -110,7 +111,7 @@ def apply_filters(self, user_ids, course_key, notification_type) -> list:
110111
applicable_filters = notification_config.get('filters', [])
111112
course = modulestore().get_course(course_key)
112113
for filter_name in applicable_filters:
113-
logger.info(
114+
logger.debug(
114115
"NotificationFilter: Applying filter %s for notification type %s",
115116
filter_name,
116117
notification_type,

openedx/core/djangoapps/notifications/tasks.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)