Checklisty: procent postępu liczony wg szacowanego czasu
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user