fix: Get latest existing notification for grouping (#36614)

This commit is contained in:
Hassan Raza
2025-04-28 20:10:00 +05:00
committed by GitHub
parent 36bd075c9a
commit 1a28a2df3b
2 changed files with 2 additions and 2 deletions

View File

@@ -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

View File

@@ -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