Skip to content

Commit 3cb1ef2

Browse files
committed
feat(local-unit): set email notification delays by environment
1 parent 43de852 commit 3cb1ef2

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

deploy/helm/ifrcgo-helm/values.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,8 @@ cronjobs:
272272
schedule: '0 0 * * 0'
273273
- command: 'ingest_icrc'
274274
schedule: '0 3 * * 0'
275-
# NOTE: Disabling local unit email notification for now
276-
# - command: 'notify_validators'
277-
# schedule: '0 0 * * *'
275+
- command: 'notify_validators'
276+
schedule: '0 0 * * *'
278277
# https://github.com/jazzband/django-oauth-toolkit/blob/master/docs/management_commands.rst#cleartokens
279278
- command: 'oauth_cleartokens'
280279
schedule: '0 1 * * *'

local_units/management/commands/notify_validators.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from datetime import timedelta
22

3+
from django.conf import settings
34
from django.core.management.base import BaseCommand
45
from django.template.loader import render_to_string
56
from django.utils import timezone
@@ -21,21 +22,28 @@ class Command(BaseCommand):
2122
@monitor(monitor_slug=SentryMonitor.NOTIFY_VALIDATORS)
2223
def handle(self, *args, **options):
2324
self.stdout.write(self.style.NOTICE("Notifying the validators..."))
24-
25+
# NOTE: In production use standard email notification time(7days/14days),shorter delays(1day/2days) elsewhere for testing
26+
production = settings.GO_ENVIRONMENT == "production"
27+
if production:
28+
regional_email_notification_days = 7
29+
global_email_notification_days = 14
30+
else:
31+
regional_email_notification_days = 1
32+
global_email_notification_days = 2
2533
# Regional Validators: 14 days
2634
queryset_for_regional_validators = LocalUnit.objects.filter(
2735
status__in=[LocalUnit.Status.UNVALIDATED, LocalUnit.Status.PENDING_EDIT_VALIDATION],
2836
is_deprecated=False,
2937
last_sent_validator_type=Validator.LOCAL,
30-
created_at__lte=timezone.now() - timedelta(days=7),
38+
created_at__lte=timezone.now() - timedelta(days=regional_email_notification_days),
3139
)
3240

3341
# Global Validators: 28 days
3442
queryset_for_global_validators = LocalUnit.objects.filter(
3543
status__in=[LocalUnit.Status.UNVALIDATED, LocalUnit.Status.PENDING_EDIT_VALIDATION],
3644
is_deprecated=False,
3745
last_sent_validator_type=Validator.REGIONAL,
38-
created_at__lte=timezone.now() - timedelta(days=14),
46+
created_at__lte=timezone.now() - timedelta(days=global_email_notification_days),
3947
)
4048

4149
for local_unit in queryset_for_regional_validators:

main/sentry.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ class SentryMonitor(models.TextChoices):
128128
INGEST_NS_DOCUMENT = "ingest_ns_document", "0 0 * * 0"
129129
INGEST_NS_INITIATIVES = "ingest_ns_initiatives", "0 0 * * 0"
130130
INGEST_ICRC = "ingest_icrc", "0 3 * * 0"
131-
# NOTE: Disabling local unit email notification for now
132-
# NOTIFY_VALIDATORS = "notify_validators", "0 0 * * *"
131+
NOTIFY_VALIDATORS = "notify_validators", "0 0 * * *"
133132
OAUTH_CLEARTOKENS = "oauth_cleartokens", "0 1 * * *"
134133

135134
@staticmethod

0 commit comments

Comments
 (0)