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:
|
||||||
Task.objects.filter(group="Scrape Data from MembershipWorks")
|
last_run_time = naturaltime(
|
||||||
.order_by("started")
|
Task.objects.filter(group="Scrape Data from MembershipWorks")
|
||||||
.last()
|
.values_list("started", flat=True)
|
||||||
)
|
.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