]> git.parisson.com Git - teleforma.git/commitdiff
add time range options
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 5 Jul 2022 16:59:12 +0000 (18:59 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 5 Jul 2022 16:59:12 +0000 (18:59 +0200)
teleforma/management/commands/teleforma-publish-notify-conferences.py

index dd87ebb0b13b0d9569bcd4edfe8b0059e4e9615f..8d404fccf99595d9b7d748cca5daa3ed85bd2637 100644 (file)
@@ -17,6 +17,9 @@ from teleforma.views.core import get_courses
 import datetime
 
 
+MINUTES_LOW_RANGE = 30
+MINUTES_HIGH_RANGE = 1
+
 class Logger:
     """A logging object"""
 
@@ -41,6 +44,12 @@ class Command(BaseCommand):
         parser.add_argument('--period', type=str, required=True,
                             help='period to process')
 
+        parser.add_argument('--minute-low-range', type=int, required=False,
+                            help='minute low range')
+
+        parser.add_argument('--minute-high-range', type=int, required=False,
+                            help='minute high range')
+
     def handle(self, *args, **options):
         logpath = options['logfile']
         logger = Logger(logpath)
@@ -48,8 +57,19 @@ class Command(BaseCommand):
         period_name = options['period']
         period = Period.objects.get(name=period_name)
 
-        now_minus = datetime.datetime.now() - datetime.timedelta(minutes=30)
-        now_plus = datetime.datetime.now() + datetime.timedelta(minutes=5)
+        minute_low_range = options['minute-low-range']
+        if not minute_low_range:
+            minute_low_range = MINUTES_LOW_RANGE
+
+        minute_high_range = options['minute-high-range']
+        if not minute_high_range:
+            minute_high_range = MINUTES_HIGH_RANGE
+
+        print(minute_low_range)
+        print(minute_high_range)
+
+        now_minus = datetime.datetime.now() - datetime.timedelta(minutes=minute_low_range)
+        now_plus = datetime.datetime.now() + datetime.timedelta(minutes=minute_high_range)
 
         conferences = Conference.objects.filter(
                         period=period,