File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1+ BEGIN ;
2+
3+ ALTER TABLE notification ADD COLUMN notification_sent BOOL DEFAULT FALSE;
4+
5+ END;
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ CREATE TABLE notification (
109109 body TEXT ,
110110 template_id TEXT , -- MB Mail template id.
111111 template_params JSONB, -- params for given MB Mail template.
112+ notification_sent BOOL DEFAULT FALSE,
112113
113114 CONSTRAINT mail_type CHECK (
114115 -- caller needs to provide either (subject and body) or (template_id and template_params).
Original file line number Diff line number Diff line change @@ -228,7 +228,8 @@ def get_digest_notifications() -> List[dict]:
228228 query = sqlalchemy .text (
229229 """
230230 SELECT
231- notification.musicbrainz_row_id
231+ notification.id
232+ ,notification.musicbrainz_row_id
232233 ,notification.subject
233234 ,notification.body
234235 ,notification.template_id
@@ -238,12 +239,13 @@ def get_digest_notifications() -> List[dict]:
238239 FROM
239240 notification
240241 JOIN
241- user_preference ON notification.musicbrainz_row_id = user_preference.musicbrainz_row_id
242-
242+ user_preference
243+ ON
244+ notification.musicbrainz_row_id = user_preference.musicbrainz_row_id
243245 WHERE
244246 user_preference.digest = true
245247 AND (notification.created + (INTERVAL '1 day' * user_preference.digest_age)) <= NOW()
246- AND notification.read = false
248+ AND notification.notification_sent = false
247249 """
248250 )
249251 result = connection .execute (query )
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ class Notification(db.Model):
3333 body = db .Column (db .Text )
3434 template_id = db .Column (db .Text )
3535 template_params = db .Column (JSONB )
36+ notification_sent = db .Column (db .Boolean , default = False )
3637
3738 __table_args__ = (
3839 db .CheckConstraint (
You can’t perform that action at this time.
0 commit comments