update getreport function

This commit is contained in:
Adrian Zürcher
2026-02-11 14:52:20 +01:00
parent f2d20e83d6
commit 376ba27a9c
2 changed files with 25 additions and 11 deletions

View File

@@ -68,12 +68,16 @@ func (a *APIHandler) GetReport(c *gin.Context) {
}
for _, e := range events {
var includesDate bool
for _, d := range request.Date {
if !strings.Contains(e.Date, d) {
continue
if strings.Contains(e.Date, d) {
includesDate = true
}
}
if !includesDate {
continue
}
var data *models.Data
if _, ok := count[e.Day]; !ok {
@@ -83,7 +87,7 @@ func (a *APIHandler) GetReport(c *gin.Context) {
data, ok := report.Data[e.Day]
if !ok {
data = &models.Data{}
data = &models.Data{Minimal: len(e.Attendees)}
report.Data[e.Day] = data
}
@@ -95,13 +99,14 @@ func (a *APIHandler) GetReport(c *gin.Context) {
data.Maximal = len(e.Attendees)
}
count[e.Day].total = +len(e.Attendees)
count[e.Day].total += len(e.Attendees)
data.Average = count[e.Day].total / count[e.Day].event
for _, a := range e.Attendees {
if _, ok := addedMember[a.Id]; ok {
continue
}
report.Attendees = append(report.Attendees, a)
addedMember[a.Id] = true
}
@@ -126,7 +131,6 @@ func (a *APIHandler) GetReport(c *gin.Context) {
} else if !slices.Contains(request.Groups, m.Group.Id) {
continue
}
}
report.NonAttendees = append(report.NonAttendees, &m)
}