Compare commits

...

4 Commits

Author SHA1 Message Date
Adrian Zürcher
03ace00a4b remove omitempty 2026-02-11 15:39:36 +01:00
Adrian Zürcher
57ef3b92db go mod tidy 2026-02-11 14:54:00 +01:00
Adrian Zürcher
ce8d17b3c9 update dbhandler for key search 2026-02-11 14:52:31 +01:00
Adrian Zürcher
376ba27a9c update getreport function 2026-02-11 14:52:20 +01:00
5 changed files with 31 additions and 17 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)
}

2
go.mod
View File

@@ -3,7 +3,7 @@ module gitea.tecamino.com/paadi/memberDB
go 1.25.4
require (
gitea.tecamino.com/paadi/dbHandler v1.1.10
gitea.tecamino.com/paadi/dbHandler v1.1.11
gitea.tecamino.com/paadi/tecamino-logger v0.2.1
github.com/gin-contrib/cors v1.7.6
github.com/gin-gonic/gin v1.11.0

4
go.sum
View File

@@ -1,5 +1,5 @@
gitea.tecamino.com/paadi/dbHandler v1.1.10 h1:zZQbDTJ0bu6CIW90Zms8yYIzTLHtWPNhVKRxLUXEDuE=
gitea.tecamino.com/paadi/dbHandler v1.1.10/go.mod h1:y/xn/POJg1DO++67uKvnO23lJQgh+XFQq7HZCS9Getw=
gitea.tecamino.com/paadi/dbHandler v1.1.11 h1:hTpMWRr4dW7TkiBnEku0/3ggDC7/uP82U9paRKY/QEs=
gitea.tecamino.com/paadi/dbHandler v1.1.11/go.mod h1:y/xn/POJg1DO++67uKvnO23lJQgh+XFQq7HZCS9Getw=
gitea.tecamino.com/paadi/tecamino-logger v0.2.1 h1:sQTBKYPdzn9mmWX2JXZBtGBvNQH7cuXIwsl4TD0aMgE=
gitea.tecamino.com/paadi/tecamino-logger v0.2.1/go.mod h1:FkzRTldUBBOd/iy2upycArDftSZ5trbsX5Ira5OzJgM=
github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=

View File

@@ -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,9 +95,13 @@ func (dh *DatabaseHandler) GetReport(filter models.ReportFilter) (report models.
for _, m := range members {
if _, ok := addedMember[m.Id]; ok {
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)
}

View File

@@ -13,7 +13,7 @@ type Report struct {
}
type Data struct {
Minimal int `json:"minimal,omitempty"`
Average int `json:"average,omitempty"`
Maximal int `json:"maximal,omitempty"`
Minimal int `json:"minimal"`
Average int `json:"average"`
Maximal int `json:"maximal"`
}