jfrag1 commented on code in PR #25239:
URL: https://github.com/apache/superset/pull/25239#discussion_r1327818883


##########
superset/tasks/cron_util.py:
##########
@@ -39,9 +39,9 @@ def cron_schedule_window(cron: str, timezone: str) -> 
Iterator[datetime]:
         logger.warning("Timezone %s was invalid. Falling back to 'UTC'", 
timezone)
     utc = pytz_timezone("UTC")
     # convert the current time to the user's local time for comparison
-    time_now = time_now.astimezone(tz)
-    start_at = time_now - timedelta(seconds=1)
-    stop_at = time_now + timedelta(seconds=window_size)
+    time_now = triggered_at.astimezone(tz)
+    start_at = time_now - timedelta(seconds=window_size / 2)
+    stop_at = time_now + timedelta(seconds=window_size / 2)

Review Comment:
   I believe this could lead to a situation where an alert/report is triggered 
more times that desired.  For example, if a report runs at 12:00:00, and the 
celery queue is backed up from 11:55:00-12:00:01, all 5-6 queued scheduler jobs 
could run one after another, and each would trigger the report.
   
   With the approach on this PR, the windows in this situation would be 
11:54:30-11:55:30, 11:55:30-11:56:30, etc., so it should ensure we don't miss 
any scheduled alerts & reports or run any more times than desired.
   
   Let me know if I'm missing something/there's something I'm not considering



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to