Checklisty: procent postępu liczony wg szacowanego czasu

This commit is contained in:
Jakub Zych
2026-10-30 18:07:36 +01:00
parent 9677e58288
commit a075963c4c
45 changed files with 57 additions and 49 deletions

View File

@@ -28,7 +28,9 @@ var checklistsRules = []lagoon.RequestRule{
{Field: "meeting", Rules: lagoon.ParseRules("nullable|integer|min:1")},
}
// checklistProgress counts a checklist's items.
// checklistProgress counts a checklist's items. Percent weighs them by
// estimate_minutes, so a 3 h item counts more than a 5 min one; without any
// estimate it counts items.
type checklistProgress struct {
Total int `json:"total"`
Done int `json:"done"`
@@ -51,7 +53,11 @@ func (p *checklistProgress) add(item checklistItemJSON) {
} else {
p.MinutesLeft += minutes
}
p.Percent = p.Done * 100 / p.Total
if p.MinutesTotal > 0 {
p.Percent = p.MinutesDone * 100 / p.MinutesTotal
} else {
p.Percent = p.Done * 100 / p.Total
}
}
// checklistMeetingRef is the short form of a checklist's zjazd.