1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat: comprehensive summary-level filtering (resolve #262)

This commit is contained in:
Ferdinand Mütsch
2021-12-26 17:02:14 +01:00
parent 8a3e6f0179
commit a279548c89
25 changed files with 333 additions and 183 deletions

View File

@ -21,7 +21,7 @@ func NewDurationService(heartbeatService IHeartbeatService) *DurationService {
return srv
}
func (srv *DurationService) Get(from, to time.Time, user *models.User) (models.Durations, error) {
func (srv *DurationService) Get(from, to time.Time, user *models.User, filters *models.Filters) (models.Durations, error) {
heartbeats, err := srv.heartbeatService.GetAllWithin(from, to, user)
if err != nil {
return nil, err
@ -34,6 +34,10 @@ func (srv *DurationService) Get(from, to time.Time, user *models.User) (models.D
mapping := make(map[string][]*models.Duration)
for _, h := range heartbeats {
if filters != nil && !filters.Match(h) {
continue
}
d1 := models.NewDurationFromHeartbeat(h)
if list, ok := mapping[d1.GroupHash]; !ok || len(list) < 1 {