diff --git a/src/server/BreCal/notifications/notifier.py b/src/server/BreCal/notifications/notifier.py index 41b89f4..916059f 100644 --- a/src/server/BreCal/notifications/notifier.py +++ b/src/server/BreCal/notifications/notifier.py @@ -313,13 +313,17 @@ class Notifier(): @staticmethod def create_notifications_for_user_list(shipcall, users:list[model.User]): + notification_type_list = [] for user in users: - notification_type_list = Notifier.build_notification_type_list(user) + user_notification_type_list = Notifier.build_notification_type_list(user) + notification_type_list.extend(user_notification_type_list) - for notification_type in notification_type_list: - schemaModel = dict(shipcall_id = shipcall.id, level = int(shipcall.evaluation), type = notification_type, message = "", created = datetime.datetime.now(), modified=None) - query = SQLQuery.get_notifications_post(schemaModel) - schemas = execute_sql_query_standalone(query=query, param=schemaModel, command_type="execute") + # get the unique notification types + notification_type_list = list(set(notification_type_list)) + for notification_type in notification_type_list: + schemaModel = dict(shipcall_id = shipcall.id, level = int(shipcall.evaluation), type = notification_type, message = "", created = datetime.datetime.now(), modified=None) + query = SQLQuery.get_notifications_post(schemaModel) + schemas = execute_sql_query_standalone(query=query, param=schemaModel, command_type="execute") return @staticmethod