Fix notification system to use the new tuple correctly

This commit is contained in:
Joseph Schorr 2017-07-13 22:43:26 +03:00
parent 9f4ffca736
commit bf3e941d7f
5 changed files with 28 additions and 72 deletions

View file

@ -4,6 +4,14 @@ from data import model
from workers.notificationworker.models_interface import (
NotificationWorkerDataInterface, Notification, Repository)
def notification(notification_row):
""" Converts the given notification row into a notification tuple. """
return Notification(uuid=notification_row.uuid, event_name=notification_row.event.name,
method_name=notification_row.method.name,
event_config_dict=json.loads(notification_row.event_config_json),
method_config_dict=json.loads(notification_row.config_json),
repository=Repository(notification_row.repository.namespace_user.username,
notification_row.repository.name))
class PreOCIModel(NotificationWorkerDataInterface):
def get_enabled_notification(self, notification_uuid):
@ -12,12 +20,7 @@ class PreOCIModel(NotificationWorkerDataInterface):
except model.InvalidNotificationException:
return None
return Notification(uuid=notification_uuid, event_name=notification_row.event.name,
method_name=notification_row.method.name,
event_config_dict=json.loads(notification_row.event_config_json),
method_config_dict=json.loads(notification_row.config_json),
repository=Repository(notification_row.repository.namespace_user.username,
notification_row.repository.name))
return notification(notification_row)
def reset_number_of_failures_to_zero(self, notification):
model.notification.reset_notification_number_of_failures(