Esempio n. 1
0
def break_into_intervals(days, start_time: str, now: datetime):
    delta = timedelta(days=days)
    start_dt = dt_parse(start_time)
    while start_dt < now:
        end_dt = min(start_dt + delta, now)
        yield start_dt, end_dt
        start_dt = end_dt
Esempio n. 2
0
 def _should_run_full_sync(self, ctx):
     sync_days = ctx.config.get("chats_full_sync_days")
     if sync_days:
         last_sync = ctx.state.get("chats_last_full_sync")
         if not last_sync:
             LOGGER.info("Running full sync of chats: no last sync time")
             return True
         next_sync = dt_parse(last_sync) + timedelta(days=sync_days)
         if next_sync <= datetime.utcnow():
             LOGGER.info("Running full sync of chats: "
                         "last sync was {}, configured to run every {} days"
                         .format(last_sync, sync_days))
             return True
     return False