Skip to content

Commit

Permalink
Use minutes instead of hours for download time delta
Browse files Browse the repository at this point in the history
  • Loading branch information
danniel committed May 27, 2024
1 parent 85cdd1c commit f708395
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion backend/donations/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ def post(self, request, *args, **kwargs):
try:
latest_job: Job = Job.objects.filter(ngo=ngo).latest("date_created")

form_retry_threshold = timezone.now() - timezone.timedelta(hours=settings.TIMEDELTA_FORMS_DOWNLOAD_HOURS)
form_retry_threshold = timezone.now() - timezone.timedelta(
minutes=settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES
)
if latest_job.status != JobStatusChoices.ERROR and latest_job.date_created > form_retry_threshold:
return redirect(reverse("contul-meu"))

Expand Down
4 changes: 2 additions & 2 deletions backend/donations/views/my_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get(self, request: HttpRequest, *args, **kwargs):

timedelta = timezone.timedelta(0)
if last_job_status != JobStatusChoices.ERROR:
timedelta = timezone.timedelta(hours=settings.TIMEDELTA_FORMS_DOWNLOAD_HOURS)
timedelta = timezone.timedelta(minutes=settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES)

if last_job_date > now - timedelta:
last_job_was_recent = True
Expand All @@ -159,7 +159,7 @@ def get(self, request: HttpRequest, *args, **kwargs):
"disable_new_download": disable_forms_download,
"disable_past_download": disable_past_download,
"contact_email": settings.CONTACT_EMAIL_ADDRESS,
"hours_between_retries": settings.TIMEDELTA_FORMS_DOWNLOAD_HOURS,
"minutes_between_retries": settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES,
"has_signed_form": has_signed_form,
"current_year": now.year,
"ngo_url": ngo_url,
Expand Down
4 changes: 2 additions & 2 deletions backend/redirectioneaza/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
LOG_LEVEL=(str, "INFO"),
ENABLE_CACHE=(bool, True),
ENABLE_FORMS_DOWNLOAD=(bool, True),
TIMEDELTA_FORMS_DOWNLOAD_HOURS=(int, 6),
TIMEDELTA_FORMS_DOWNLOAD_MINUTES=(int, 360),
IS_CONTAINERIZED=(bool, False),
RECAPTCHA_ENABLED=(bool, True),
# proxy headers
Expand Down Expand Up @@ -619,7 +619,7 @@
SILENCED_SYSTEM_CHECKS = ["django_recaptcha.recaptcha_test_key_error"]

ENABLE_FORMS_DOWNLOAD = env.bool("ENABLE_FORMS_DOWNLOAD", True)
TIMEDELTA_FORMS_DOWNLOAD_HOURS = env.int("TIMEDELTA_FORMS_DOWNLOAD_HOURS")
TIMEDELTA_FORMS_DOWNLOAD_MINUTES = env.int("TIMEDELTA_FORMS_DOWNLOAD_MINUTES")


# encryption
Expand Down
6 changes: 3 additions & 3 deletions backend/templates/v1/ngo/donations-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{% endif %}
<br>
Deoarece operația de descărcare a declarațiilor poate dura mai mult timp, în funcție de numărul de donatori,
momentan puteți descărca o singură arhivă la fiecare {{ hours_between_retries }} ore.
momentan puteți descărca o singură arhivă la fiecare {{ minutes_between_retries }} minute.
</p>
{% endif %}

Expand Down Expand Up @@ -67,8 +67,8 @@
Descărcarea de declarații este momentan blocată pentru organizația ta.
<br>
Descărcarea de declarații este limitată la una singură la fiecare
{{ hours_between_retries }}
ore.
{{ minutes_between_retries }}
minute.
</div>
{% endif %}
<button id="download-button" class="btn" type="submit"
Expand Down
4 changes: 2 additions & 2 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ module "ecs_redirectioneaza" {
value = 4
},
{
name = "TIMEDELTA_FORMS_DOWNLOAD_HOURS"
value = 2
name = "TIMEDELTA_FORMS_DOWNLOAD_MINUTES"
value = 20
},
{
name = "DONATIONS_LIMIT_DAY"
Expand Down

0 comments on commit f708395

Please sign in to comment.