-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-cl-xml-from-cap
- Loading branch information
Showing
38 changed files
with
3,686 additions
and
566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
cl/alerts/management/commands/cl_send_rt_percolator_alerts.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import time | ||
|
||
from cl.alerts.management.commands.cl_send_scheduled_alerts import ( | ||
query_and_send_alerts_by_rate, | ||
) | ||
from cl.alerts.models import Alert | ||
from cl.lib.command_utils import VerboseCommand | ||
|
||
|
||
class Command(VerboseCommand): | ||
help = """Send real-time alerts scheduled by the Percolator every 5 minutes. | ||
This process is performed to accumulate alerts that can be grouped into a | ||
single email if they belong to the same user. """ | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.options = {} | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"--testing-mode", | ||
action="store_true", | ||
help="Use this flag for testing purposes.", | ||
) | ||
|
||
def handle(self, *args, **options): | ||
super().handle(*args, **options) | ||
testing_mode = options.get("testing_mode", False) | ||
while True: | ||
query_and_send_alerts_by_rate(Alert.REAL_TIME) | ||
if testing_mode: | ||
# Perform only 1 iteration for testing purposes. | ||
break | ||
|
||
# Wait for 5 minutes. | ||
time.sleep(300) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.