From 8ce09ab9e5826ffb5b2b763f96e7b21ebe8575ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Mon, 24 May 2021 15:17:27 +0300 Subject: [PATCH] Widen report time window to 9AM - 11AM --- hc/accounts/models.py | 6 +++--- hc/api/tests/test_sendreports.py | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hc/accounts/models.py b/hc/accounts/models.py index 4498e4e3..1a9b3d56 100644 --- a/hc/accounts/models.py +++ b/hc/accounts/models.py @@ -289,10 +289,10 @@ class Profile(models.Model): """ Calculate the target date for the next monthly/weekly report. Monthly reports should get sent on 1st of each month, between - 9AM and 10AM in user's timezone. + 9AM and 11AM in user's timezone. Weekly reports should get sent on Mondays, between - 9AM and 10AM in user's timezone. + 9AM and 11AM in user's timezone. """ @@ -301,7 +301,7 @@ class Profile(models.Model): tz = pytz.timezone(self.tz) dt = timezone.now().astimezone(tz) - dt = dt.replace(hour=9, minute=random.randrange(0, 60)) + dt = dt.replace(hour=9, minute=0) + timedelta(minutes=random.randrange(0, 120)) while True: dt += timedelta(days=1) diff --git a/hc/api/tests/test_sendreports.py b/hc/api/tests/test_sendreports.py index e790dfc1..fece30ad 100644 --- a/hc/api/tests/test_sendreports.py +++ b/hc/api/tests/test_sendreports.py @@ -64,7 +64,6 @@ class SendReportsTestCase(BaseTestCase): self.assertTrue(found) self.profile.refresh_from_db() - self.assertTrue(self.profile.next_report_date) self.assertEqual(self.profile.next_report_date.day, 1) self.assertEqual(len(mail.outbox), 0)