Skip to content

Commit

Permalink
fix: add tqdm as a dependency (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonylucas74 authored Jul 19, 2024
1 parent 614e06a commit 40b8813
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
13 changes: 12 additions & 1 deletion backend/apps/core/admin.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
# -*- coding: utf-8 -*-
from datetime import timedelta

from django.contrib import admin

from .models import TaskExecution


class TaskExecutionAdmin(admin.ModelAdmin):
list_display = ["task_name", "execution_time", "status", "duration"]
list_display = ["task_name", "execution_time", "status", "formatted_duration"]
readonly_fields = ["task_name", "execution_time", "duration", "status", "result", "error"]

def has_add_permission(self, request):
return False

def formatted_duration(self, obj):
duration_seconds = obj.duration
duration = timedelta(seconds=duration_seconds)
minutes = duration.seconds // 60
seconds = duration.seconds % 60
return f"{minutes} minutes and {seconds} seconds"

formatted_duration.short_description = "Duration"


admin.site.register(TaskExecution, TaskExecutionAdmin)
2 changes: 1 addition & 1 deletion backend/custom/task_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def wrapper(*args, **kwargs):
try:
result = func(*args, **kwargs)
except Exception as e:
status = "falied"
status = "failed"
error = str(e)
finally:
end_time = datetime.now()
Expand Down
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ stripe = "^4.2.0"
dj-stripe = "^2.8.3"
pydantic = "^2.5.3"
requests = "^2.31.0"
tqdm = "^4.66.4"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.3.3"
Expand Down

0 comments on commit 40b8813

Please sign in to comment.