diff options
| author | Magnus Hagander | 2024-09-11 15:21:01 +0000 |
|---|---|---|
| committer | Magnus Hagander | 2024-09-11 15:21:01 +0000 |
| commit | 50c8db8763c2246c03007e6d11fefebeb55631c4 (patch) | |
| tree | 36b1d11b703978b68da19cbdfdc6be8b57fc4973 /postgresqleu | |
| parent | 1113b5e748f3af130043890d185030ac669dbf1d (diff) | |
For failed social media posts, show time for next attempt
Diffstat (limited to 'postgresqleu')
| -rw-r--r-- | postgresqleu/confreg/backendforms.py | 6 | ||||
| -rw-r--r-- | postgresqleu/util/messaging/sender.py | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/postgresqleu/confreg/backendforms.py b/postgresqleu/confreg/backendforms.py index c5222d15..389b0a76 100644 --- a/postgresqleu/confreg/backendforms.py +++ b/postgresqleu/confreg/backendforms.py @@ -1687,6 +1687,12 @@ class BackendTweetQueueForm(BackendForm): self.fields['status'].initial = '<br/>'.join("{}: {}".format(*p) for p in postedstatus) self.order_fields(['datetime', 'approved', 'textcontents', 'image', 'comment', 'status']) + if self.instance and self.instance.approved and not self.instance.sent and self.instance.errorcount > 0: + self.fields['status'].initial += '<br/><br/>Next retry to post at {}'.format( + # NOTE! The pow() formula should be kept in sync with util/messaging/sender.py + self.instance.datetime + datetime.timedelta(seconds=pow(2.25, self.instance.errorcount + 4)), + ) + self.update_protected_fields() def pre_create_item(self): diff --git a/postgresqleu/util/messaging/sender.py b/postgresqleu/util/messaging/sender.py index 73dc3701..3274a4dd 100644 --- a/postgresqleu/util/messaging/sender.py +++ b/postgresqleu/util/messaging/sender.py @@ -102,6 +102,7 @@ def _send_pending_posts(providers): # Get all pending tweets to post. If a tweet has errors on it, it get postponed by # the very unscientific formula of 2.25^(errorcount+4) up to 10 attempts, which means # the first retry is after ~ 1 minute and the last one after ~24 hours. + # NOTE! The pow() formula should be kept in sync with confreg/backendforms.py, BackendTweetQueueForm tlist = list(ConferenceTweetQueue.objects.raw("""SELECT * FROM confreg_conferencetweetqueue WHERE approved AND NOT sent AND datetime + CASE WHEN errorcount>0 THEN pow(2.25, errorcount+4) * '1 second'::interval ELSE '0' END <= CURRENT_TIMESTAMP |
