membershipworks: Slightly simplify admin task "last run time" logic
This commit is contained in:
parent
1fe097ca86
commit
27c705668c
@ -36,14 +36,14 @@ class BaseMembershipWorksAdmin(DjangoObjectActions, ReadOnlyAdmin):
|
|||||||
def _get_tool_dict(self, tool_name):
|
def _get_tool_dict(self, tool_name):
|
||||||
tool = super(DjangoObjectActions, self)._get_tool_dict(tool_name)
|
tool = super(DjangoObjectActions, self)._get_tool_dict(tool_name)
|
||||||
if tool_name == "refresh_membershipworks_data":
|
if tool_name == "refresh_membershipworks_data":
|
||||||
last_run = (
|
try:
|
||||||
|
last_run_time = naturaltime(
|
||||||
Task.objects.filter(group="Scrape Data from MembershipWorks")
|
Task.objects.filter(group="Scrape Data from MembershipWorks")
|
||||||
.order_by("started")
|
.values_list("started", flat=True)
|
||||||
.last()
|
.latest("started")
|
||||||
)
|
|
||||||
last_run_time = (
|
|
||||||
naturaltime(last_run.started) if last_run is not None else "Never"
|
|
||||||
)
|
)
|
||||||
|
except Task.DoesNotExist:
|
||||||
|
last_run_time = "Never"
|
||||||
tool["label"] = f"Refresh Data [Last Run {last_run_time}]"
|
tool["label"] = f"Refresh Data [Last Run {last_run_time}]"
|
||||||
return tool
|
return tool
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user