mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Call publish-govuk-alerts task when alert expires
The `auto-expire-broadcast-messages` task checks for expired broadcasts at five minute intervals. This change now calls the `publish-govuk-alerts` task in govuk-alerts if there are expired broadcasts so that the site is updated. Co-authored-by: Katie Smith <katie.smith@digital.cabinet-office.gov.uk>
This commit is contained in:
committed by
Katie Smith
parent
04bfd6bfdb
commit
1b6f9505da
@@ -16,7 +16,7 @@ from app.celery.tasks import (
|
||||
process_job,
|
||||
process_row,
|
||||
)
|
||||
from app.config import QueueNames
|
||||
from app.config import QueueNames, TaskNames
|
||||
from app.dao.invited_org_user_dao import (
|
||||
delete_org_invitations_created_more_than_two_days_ago,
|
||||
)
|
||||
@@ -322,9 +322,15 @@ def auto_expire_broadcast_messages():
|
||||
expired_broadcasts = BroadcastMessage.query.filter(
|
||||
BroadcastMessage.finishes_at <= datetime.now(),
|
||||
BroadcastMessage.status == BroadcastStatusType.BROADCASTING,
|
||||
)
|
||||
).all()
|
||||
|
||||
for broadcast in expired_broadcasts:
|
||||
broadcast.status = BroadcastStatusType.COMPLETED
|
||||
|
||||
db.session.commit()
|
||||
|
||||
if expired_broadcasts:
|
||||
notify_celery.send_task(
|
||||
name=TaskNames.PUBLISH_GOVUK_ALERTS,
|
||||
queue=QueueNames.GOVUK_ALERTS
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user