liquid_feedback_frontend
changeset 1629:c5c18a861b85
Fixed display of last counting
author | bsw |
---|---|
date | Mon Feb 08 01:39:43 2021 +0100 (2021-02-08) |
parents | e89476678783 |
children | 86a45c381bd9 |
files | app/main/issue/show.lua model/snapshot.lua |
line diff
1.1 --- a/app/main/issue/show.lua Mon Feb 08 01:05:04 2021 +0100 1.2 +++ b/app/main/issue/show.lua Mon Feb 08 01:39:43 2021 +0100 1.3 @@ -51,8 +51,9 @@ 1.4 readonly = true, 1.5 attr = { class = "sectionRow form" }, 1.6 content = function() 1.7 - if issue.snapshot then 1.8 - ui.field.timestamp{ label = _"Last counting:", value = issue.snapshot } 1.9 + local latest_snapshot = Snapshot:latest_by_issue_id(issue.id) 1.10 + if latest_snapshot then 1.11 + ui.field.timestamp{ label = _"Last counting:", value = latest_snapshot.calculated } 1.12 end 1.13 ui.field.text{ label = _"Population", name = "population" } 1.14 ui.field.timestamp{ label = _"Created at", name = "created" }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/model/snapshot.lua Mon Feb 08 01:39:43 2021 +0100 2.3 @@ -0,0 +1,12 @@ 2.4 +Snapshot = mondelefant.new_class() 2.5 +Snapshot.table = 'snapshot' 2.6 +Snapshot.primary_key = "id" 2.7 + 2.8 +function Snapshot:latest_by_issue_id(issue_id) 2.9 + return self:new_selector() 2.10 + :add_where{ "issue_id = ?", issue_id } 2.11 + :add_order_by("id DESC") 2.12 + :limit(1) 2.13 + :optional_object_mode() 2.14 + :exec() 2.15 +end