update getreport function
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -42,11 +42,16 @@ func (dh *DatabaseHandler) GetReport(filter models.ReportFilter) (report models.
|
||||
|
||||
for _, e := range events {
|
||||
|
||||
var includesDate bool
|
||||
|
||||
for _, d := range filter.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 {
|
||||
@@ -56,7 +61,7 @@ func (dh *DatabaseHandler) GetReport(filter models.ReportFilter) (report models.
|
||||
|
||||
data, ok := report.Data[e.Day]
|
||||
if !ok {
|
||||
data = &models.Data{}
|
||||
data = &models.Data{Minimal: len(e.Attendees)}
|
||||
report.Data[e.Day] = data
|
||||
}
|
||||
|
||||
@@ -68,13 +73,14 @@ func (dh *DatabaseHandler) GetReport(filter models.ReportFilter) (report models.
|
||||
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
|
||||
}
|
||||
@@ -89,8 +95,12 @@ func (dh *DatabaseHandler) GetReport(filter models.ReportFilter) (report models.
|
||||
for _, m := range members {
|
||||
if _, ok := addedMember[m.Id]; ok {
|
||||
continue
|
||||
} else if !slices.Contains(filter.Groups, m.Group.Id) {
|
||||
continue
|
||||
} else if len(filter.Groups) > 0 {
|
||||
if m.Group == nil {
|
||||
continue
|
||||
} else if !slices.Contains(filter.Groups, m.Group.Id) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
report.NonAttendees = append(report.NonAttendees, &m)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user