-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(alerts): Trigger RECAP Alerts on related documents.
- Group and send RT RECAP Search Alerts.
- Loading branch information
1 parent
8229a90
commit 32f8ca9
Showing
8 changed files
with
278 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import time | ||
|
||
from cl.alerts.management.commands.cl_send_scheduled_alerts import ( | ||
send_scheduled_alerts, | ||
) | ||
from cl.alerts.models import Alert | ||
from cl.lib.command_utils import VerboseCommand | ||
|
||
|
||
class Command(VerboseCommand): | ||
help = """Send RT Alerts for RECAP every 5 minutes. """ | ||
|
||
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: | ||
send_scheduled_alerts(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
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
Oops, something went wrong.