Skip to content

Commit

Permalink
[#3725] PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vaszig committed Apr 5, 2024
1 parent e979a9d commit 8410e69
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/openforms/emails/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def send_email_digest() -> None:
if not (recipients := config.recipients_email_digest):
return

desired_period = timezone.now() - timedelta(days=1)
yesterday = timezone.now() - timedelta(days=1)

failed_emails = collect_failed_emails(desired_period)
failed_registrations = collect_registrations_failures(desired_period)
failed_emails = collect_failed_emails(yesterday)
failed_registrations = collect_registrations_failures(yesterday)

if not (failed_emails or failed_registrations):
return
Expand Down
5 changes: 3 additions & 2 deletions src/openforms/emails/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import re
from datetime import datetime
from typing import Any, Sequence
from urllib.parse import urlsplit

Expand Down Expand Up @@ -104,9 +105,9 @@ def render_email_template(
)


def collect_failed_emails(desired_period) -> list[dict[str, str] | None]:
def collect_failed_emails(since: datetime) -> list[dict[str, str] | None]:
logs = TimelineLogProxy.objects.filter(
timestamp__gt=desired_period,
timestamp__gt=since,
extra_data__status=Message.STATUS_FAILED,
extra_data__include_in_daily_digest=True,
).distinct("content_type", "extra_data__status", "extra_data__event")
Expand Down
5 changes: 3 additions & 2 deletions src/openforms/registrations/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from typing import Any, Callable

from glom import assign, glom
Expand Down Expand Up @@ -34,9 +35,9 @@ def execute_unless_result_exists(
return callback_result


def collect_registrations_failures(desired_period) -> list[dict[str, str] | None]:
def collect_registrations_failures(since: datetime) -> list[dict[str, str] | None]:
logs = TimelineLogProxy.objects.filter(
timestamp__gt=desired_period,
timestamp__gt=since,
extra_data__log_event="registration_failure",
extra_data__include_in_daily_digest=True,
).order_by("timestamp")
Expand Down
4 changes: 2 additions & 2 deletions src/openforms/submissions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def lookups(self, request, model_admin):
]

def queryset(self, request, queryset):
desired_period = timezone.now() - timedelta(days=1)
yesterday = timezone.now() - timedelta(days=1)
if self.value() == "24hAgo":
return queryset.filter(last_register_date__gt=desired_period)
return queryset.filter(last_register_date__gt=yesterday)

Check warning on line 100 in src/openforms/submissions/admin.py

View check run for this annotation

Codecov / codecov/patch

src/openforms/submissions/admin.py#L100

Added line #L100 was not covered by tests


class SubmissionStepInline(admin.StackedInline):
Expand Down

0 comments on commit 8410e69

Please sign in to comment.