temp: add temporary logs for course wide notifications

This commit is contained in:
SaadYousaf
2023-12-28 14:32:56 +05:00
committed by Saad Yousaf
parent 30c029f119
commit 8a9e19ad8f
3 changed files with 17 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
"""
Discussion notifications sender util.
"""
import logging
from django.conf import settings
from lms.djangoapps.discussion.django_comment_client.permissions import get_team
from openedx_events.learning.data import UserNotificationData, CourseNotificationData
@@ -20,6 +22,9 @@ from openedx.core.djangoapps.django_comment_common.models import (
)
log = logging.getLogger(__name__)
class DiscussionNotificationSender:
"""
Class to send notifications to users who are subscribed to the thread.
@@ -257,6 +262,8 @@ class DiscussionNotificationSender:
'username': self.creator.username,
'post_title': self.thread.title
}
log.info(f"Temp: Audience filter for course-wide notification is {audience_filters}")
self._send_course_wide_notification(notification_type, audience_filters, context)

View File

@@ -1,6 +1,7 @@
"""
Audience based filters for notifications
"""
import logging
from abc import abstractmethod
@@ -21,6 +22,9 @@ from openedx.core.djangoapps.django_comment_common.models import (
)
log = logging.getLogger(__name__)
class NotificationAudienceFilterBase:
"""
Base class for notification audience filters
@@ -80,10 +84,12 @@ class CourseRoleAudienceFilter(NotificationAudienceFilterBase):
if 'staff' in course_roles:
staff_users = CourseStaffRole(course_key).users_with_role().values_list('id', flat=True)
log.info(f'Temp: Course wide notification, staff users calculated are {staff_users}')
user_ids.extend(staff_users)
if 'instructor' in course_roles:
instructor_users = CourseInstructorRole(course_key).users_with_role().values_list('id', flat=True)
log.info(f'Temp: Course wide notification, instructor users calculated are {instructor_users}')
user_ids.extend(instructor_users)
return user_ids

View File

@@ -96,10 +96,13 @@ def calculate_course_wide_notification_audience(course_key, audience_filters):
if filter_class:
filter_instance = filter_class(course_key)
filtered_users = filter_instance.filter(filter_values)
log.info(f'Temp: Course-wide notification filtered users are '
f'{filtered_users} for filter type {filter_type}')
audience_user_ids.extend(filtered_users)
else:
raise ValueError(f"Invalid audience filter type: {filter_type}")
log.info(f'Temp: Course-wide notification after audience filter is applied, users: {list(set(audience_user_ids))}')
return list(set(audience_user_ids))
@@ -124,4 +127,5 @@ def generate_course_notifications(signal, sender, course_notification_data, meta
'content_url': course_notification_data.get('content_url'),
}
log.info(f"Temp: Course-wide notification, user_ids to sent notifications to {notification_data.get('user_ids')}")
send_notifications.delay(**notification_data)