mirror of
https://github.com/quay/quay.git
synced 2026-01-26 06:21:37 +03:00
[redhat-3.12] events: Expose notification rerun time interval in a variable (PROJQUAY-7441) (#3012)
This commit is contained in:
@@ -1553,5 +1553,10 @@ CONFIG_SCHEMA = {
|
||||
},
|
||||
},
|
||||
},
|
||||
"NOTIFICATION_TASK_RUN_MINIMUM_INTERVAL_MINUTES": {
|
||||
"type": "number",
|
||||
"description": "Interval in minutes that defines frequency to re-run notifications",
|
||||
"x-example": 5000,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
from app import app
|
||||
from data.database import (
|
||||
ExternalNotificationEvent,
|
||||
RepositoryNotification,
|
||||
@@ -21,11 +22,13 @@ BATCH_SIZE = 10
|
||||
# since we test with mysql 5.7 which does not support this flag.
|
||||
SKIP_LOCKED = True
|
||||
|
||||
# interval in minutes that specifies how long a task must wait before being run again, defaults to 5hrs
|
||||
NOTIFICATION_TASK_RUN_MINIMUM_INTERVAL_MINUTES = app.config.get(
|
||||
"NOTIFICATION_TASK_RUN_MINIMUM_INTERVAL_MINUTES", 5 * 60
|
||||
)
|
||||
|
||||
def fetch_active_notification(event, task_run_interval_ms=5 * 60 * 60 * 1000):
|
||||
"""
|
||||
task_run_interval_ms specifies how long a task must wait before being ran again.
|
||||
"""
|
||||
|
||||
def fetch_active_notification(event):
|
||||
with db_transaction():
|
||||
try:
|
||||
# Fetch active notifications that match the event_name
|
||||
@@ -41,7 +44,8 @@ def fetch_active_notification(event, task_run_interval_ms=5 * 60 * 60 * 1000):
|
||||
RepositoryNotification.number_of_failures < 3,
|
||||
(
|
||||
RepositoryNotification.last_ran_ms
|
||||
< get_epoch_timestamp_ms() - task_run_interval_ms
|
||||
< get_epoch_timestamp_ms()
|
||||
- (NOTIFICATION_TASK_RUN_MINIMUM_INTERVAL_MINUTES * 60 * 1000)
|
||||
)
|
||||
| (RepositoryNotification.last_ran_ms.is_null(True)),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user