Skip to content

Commit 3c38896

Browse files
committed
Add notification_sent flag
1 parent 382bc7c commit 3c38896

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
BEGIN;
2+
3+
ALTER TABLE notification ADD COLUMN notification_sent BOOL DEFAULT FALSE;
4+
5+
END;

admin/sql/create_tables.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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).

metabrainz/db/notification.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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)

metabrainz/model/notification.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)