Fix mnt task min usage with an empty iterable

This commit is contained in:
DevilXD committed 2022-04-19 18:02:05 +02:00
1 parent dea5b51fed
commit 2efdda45d0
1 file changed
+4 -2
+4 -2
View File
@@ -466,10 +466,12 @@ class Twitch:
# 1h at max, but can be shorter if there's an upcoming campaign earlier than that # 1h at max, but can be shorter if there's an upcoming campaign earlier than that
# divide the period into up to two evenly spaced checks (usually ~15-30m) # divide the period into up to two evenly spaced checks (usually ~15-30m)
now = datetime.now(timezone.utc) now = datetime.now(timezone.utc)
one_hour = timedelta(hours=1)
period = min( period = min(
campaign.starts_at - now for campaign in self.inventory if campaign.starts_at > now (campaign.starts_at - now for campaign in self.inventory if campaign.starts_at > now),
default=one_hour,
) )
if period > (one_hour := timedelta(hours=1)): if period > one_hour:
period = one_hour period = one_hour
times = ceil(period.total_seconds() / 30 * 60) times = ceil(period.total_seconds() / 30 * 60)
period /= times period /= times