creating only one notification per notification_type, even if multiple users request the same notification_type.

This commit is contained in:
Max Metz 2024-07-31 12:05:48 +02:00
parent bc6d391094
commit 9709b06196

View File

@ -313,13 +313,17 @@ class Notifier():
@staticmethod @staticmethod
def create_notifications_for_user_list(shipcall, users:list[model.User]): def create_notifications_for_user_list(shipcall, users:list[model.User]):
notification_type_list = []
for user in users: 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: # get the unique notification types
schemaModel = dict(shipcall_id = shipcall.id, level = int(shipcall.evaluation), type = notification_type, message = "", created = datetime.datetime.now(), modified=None) notification_type_list = list(set(notification_type_list))
query = SQLQuery.get_notifications_post(schemaModel) for notification_type in notification_type_list:
schemas = execute_sql_query_standalone(query=query, param=schemaModel, command_type="execute") 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 return
@staticmethod @staticmethod