11from datetime import timedelta
22
3+ from django .conf import settings
34from django .core .management .base import BaseCommand
45from django .template .loader import render_to_string
56from 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 :
0 commit comments