Fixes to how import times are estimated

The wrong attr was being used to grab the number of seconds, and imports
that were stopped were being counted
This commit is contained in:
Mouse Reeve 2022-11-10 11:40:20 -08:00
parent cc95c4d7b5
commit 784dab3d41

View file

@ -45,7 +45,9 @@ class Import(View):
last_week = timezone.now() - datetime.timedelta(days=7)
recent_avg = (
models.ImportJob.objects.filter(created_date__gte=last_week, complete=True)
models.ImportJob.objects.filter(
created_date__gte=last_week, status="complete"
)
.annotate(
runtime=ExpressionWrapper(
F("updated_date") - F("created_date"),
@ -58,9 +60,9 @@ class Import(View):
if recent_avg:
seconds = recent_avg.total_seconds()
if seconds > 60**2:
data["recent_avg_hours"] = recent_avg.seconds / (60**2)
data["recent_avg_hours"] = seconds / (60**2)
else:
data["recent_avg_minutes"] = recent_avg.seconds / 60
data["recent_avg_minutes"] = seconds / 60
return TemplateResponse(request, "import/import.html", data)