# HG changeset patch # User bsw # Date 1612744783 -3600 # Node ID c5c18a861b85c035589e77df26c42c1f1b4ce636 # Parent e894766787831ca980759585b527caafbaf39bc7 Fixed display of last counting diff -r e89476678783 -r c5c18a861b85 app/main/issue/show.lua --- a/app/main/issue/show.lua Mon Feb 08 01:05:04 2021 +0100 +++ b/app/main/issue/show.lua Mon Feb 08 01:39:43 2021 +0100 @@ -51,8 +51,9 @@ readonly = true, attr = { class = "sectionRow form" }, content = function() - if issue.snapshot then - ui.field.timestamp{ label = _"Last counting:", value = issue.snapshot } + local latest_snapshot = Snapshot:latest_by_issue_id(issue.id) + if latest_snapshot then + ui.field.timestamp{ label = _"Last counting:", value = latest_snapshot.calculated } end ui.field.text{ label = _"Population", name = "population" } ui.field.timestamp{ label = _"Created at", name = "created" } diff -r e89476678783 -r c5c18a861b85 model/snapshot.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/model/snapshot.lua Mon Feb 08 01:39:43 2021 +0100 @@ -0,0 +1,12 @@ +Snapshot = mondelefant.new_class() +Snapshot.table = 'snapshot' +Snapshot.primary_key = "id" + +function Snapshot:latest_by_issue_id(issue_id) + return self:new_selector() + :add_where{ "issue_id = ?", issue_id } + :add_order_by("id DESC") + :limit(1) + :optional_object_mode() + :exec() +end