mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: properly sort durations to prevent heartbeats from being counted twice
This commit is contained in:
@ -21,7 +21,7 @@ func NewDurationService(heartbeatService IHeartbeatService) *DurationService {
|
||||
return srv
|
||||
}
|
||||
|
||||
func (srv *DurationService) Get(from, to time.Time, user *models.User) ([]*models.Duration, error) {
|
||||
func (srv *DurationService) Get(from, to time.Time, user *models.User) (models.Durations, error) {
|
||||
heartbeats, err := srv.heartbeatService.GetAllWithin(from, to, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -62,7 +62,7 @@ func (srv *DurationService) Get(from, to time.Time, user *models.User) ([]*model
|
||||
count++
|
||||
}
|
||||
|
||||
durations := make([]*models.Duration, 0, count)
|
||||
durations := make(models.Durations, 0, count)
|
||||
|
||||
for _, list := range mapping {
|
||||
for _, d := range list {
|
||||
@ -73,5 +73,5 @@ func (srv *DurationService) Get(from, to time.Time, user *models.User) ([]*model
|
||||
}
|
||||
}
|
||||
|
||||
return durations, nil
|
||||
return durations.Sorted(), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user