fix: Get latest existing notification for grouping (#36614)
This commit is contained in:
@@ -140,6 +140,6 @@ def get_user_existing_notifications(user_ids, notification_type, group_by_id, co
|
||||
notifications_mapping[notification.user_id].append(notification)
|
||||
|
||||
for user_id, notifications in notifications_mapping.items():
|
||||
notifications.sort(key=lambda elem: elem.created)
|
||||
notifications.sort(key=lambda elem: elem.created, reverse=True)
|
||||
notifications_mapping[user_id] = notifications[0] if notifications else None
|
||||
return notifications_mapping
|
||||
|
||||
@@ -188,5 +188,5 @@ class TestGetUserExistingNotifications(unittest.TestCase):
|
||||
result = get_user_existing_notifications(user_ids, notification_type, group_by_id, course_id)
|
||||
|
||||
# Verify the results
|
||||
self.assertEqual(result[1], mock_notification1)
|
||||
self.assertEqual(result[1], mock_notification2)
|
||||
self.assertIsNone(result[2]) # user 2 has no notifications
|
||||
|
||||
Reference in New Issue
Block a user