Skip to content

Commit

Permalink
send each every 24 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
madjid-asa committed Dec 28, 2023
1 parent 70009c9 commit 5b35676
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ def validated(self):
return self.filter(validated_at__isnull=False)

def validated_but_not_sent(self):
yesterday = timezone.now() - timedelta(days=1)

return self.with_siae_stats().filter(
(Q(version=0) & Q(validated_at__isnull=False) & Q(first_sent_at__isnull=True))
| (
Q(version=1)
& Q(validated_at__isnull=False)
& Q(siae_detail_contact_click_count_annotated__lte=F("limit_nb_siae_interested"))
& ~Q(siae_count_annotated=F("siae_email_send_count_annotated"))
& (Q(first_sent_at__isnull=True) | Q(last_sent_at__lt=yesterday))
)
)

Expand Down

0 comments on commit 5b35676

Please sign in to comment.