diff --git a/models/durations.go b/models/durations.go index 81c6bbb..e541c86 100644 --- a/models/durations.go +++ b/models/durations.go @@ -16,7 +16,7 @@ func (d Durations) Swap(i, j int) { d[i], d[j] = d[j], d[i] } -func (d *Durations) Sorted() *Durations { +func (d Durations) Sorted() Durations { sort.Sort(d) return d } diff --git a/services/duration.go b/services/duration.go index 591ce98..f96150f 100644 --- a/services/duration.go +++ b/services/duration.go @@ -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 } diff --git a/services/services.go b/services/services.go index 8d80cd9..4b32f55 100644 --- a/services/services.go +++ b/services/services.go @@ -75,7 +75,7 @@ type IMailService interface { } type IDurationService interface { - Get(time.Time, time.Time, *models.User) ([]*models.Duration, error) + Get(time.Time, time.Time, *models.User) (models.Durations, error) } type ISummaryService interface { diff --git a/services/summary.go b/services/summary.go index 5ae7136..161084d 100644 --- a/services/summary.go +++ b/services/summary.go @@ -58,7 +58,7 @@ func NewSummaryService(summaryRepo repositories.ISummaryRepository, durationServ func (srv *SummaryService) Aliased(from, to time.Time, user *models.User, f SummaryRetriever, skipCache bool) (*models.Summary, error) { // Check cache cacheKey := srv.getHash(from.String(), to.String(), user.ID, "--aliased") - if cacheResult, ok := srv.cache.Get(cacheKey); ok && !skipCache { + if cacheResult, ok := srv.cache.Get(cacheKey); ok && !skipCache && false { return cacheResult.(*models.Summary), nil }