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):
|
||||
tool = super(DjangoObjectActions, self)._get_tool_dict(tool_name)
|
||||
if tool_name == "refresh_membershipworks_data":
|
||||
last_run = (
|
||||
Task.objects.filter(group="Scrape Data from MembershipWorks")
|
||||
.order_by("started")
|
||||
.last()
|
||||
)
|
||||
last_run_time = (
|
||||
naturaltime(last_run.started) if last_run is not None else "Never"
|
||||
)
|
||||
try:
|
||||
last_run_time = naturaltime(
|
||||
Task.objects.filter(group="Scrape Data from MembershipWorks")
|
||||
.values_list("started", flat=True)
|
||||
.latest("started")
|
||||
)
|
||||
except Task.DoesNotExist:
|
||||
last_run_time = "Never"
|
||||
tool["label"] = f"Refresh Data [Last Run {last_run_time}]"
|
||||
return tool
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user