mirror of
https://github.com/muety/wakapi.git
synced 2025-12-06 06:22:41 -08:00
chore: move summary time zone fix into summary model
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -412,6 +412,14 @@ func (s *Summary) WithResolvedAliases(resolve AliasResolver) *Summary {
|
||||
return s
|
||||
}
|
||||
|
||||
// inplace!
|
||||
func (s *Summary) InTZ(tz *time.Location) *Summary {
|
||||
// time zone madness, see https://github.com/muety/wakapi/issues/719#issuecomment-2599365514
|
||||
s.FromTime = CustomTime(s.FromTime.T().In(tz))
|
||||
s.ToTime = CustomTime(s.ToTime.T().In(tz))
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Summary) findFirstPresentType() (uint8, error) {
|
||||
for _, t := range s.Types() {
|
||||
if s.TotalTimeBy(t) != 0 {
|
||||
|
||||
@@ -93,11 +93,6 @@ func (s *ActivityService) getChartPastYear(user *models.User, darkTheme, hideAtt
|
||||
summary.ToTime = models.CustomTime(to)
|
||||
summary.UserID = user.ID
|
||||
summary.User = user
|
||||
} else {
|
||||
// time zone madness, see https://github.com/muety/wakapi/issues/719#issuecomment-2599365514
|
||||
// alternatively, we could also just use interval[0] and interval[1] instead
|
||||
summary.FromTime = models.CustomTime(summary.FromTime.T().In(user.TZ()))
|
||||
summary.ToTime = models.CustomTime(summary.ToTime.T().In(user.TZ()))
|
||||
}
|
||||
|
||||
mut.Lock()
|
||||
|
||||
@@ -96,7 +96,7 @@ func (srv *SummaryService) Aliased(from, to time.Time, user *models.User, f type
|
||||
}
|
||||
|
||||
srv.cache.SetDefault(cacheKey, summary)
|
||||
return summary.Sorted(), nil
|
||||
return summary.Sorted().InTZ(user.TZ()), nil
|
||||
}
|
||||
|
||||
func (srv *SummaryService) Retrieve(from, to time.Time, user *models.User, filters *models.Filters) (*models.Summary, error) {
|
||||
@@ -143,7 +143,7 @@ func (srv *SummaryService) Retrieve(from, to time.Time, user *models.User, filte
|
||||
summary.KeepOnly(map[uint8]bool{filter.Entity: true}).ApplyFilter(filter)
|
||||
}
|
||||
|
||||
return summary.Sorted(), nil
|
||||
return summary.Sorted().InTZ(user.TZ()), nil
|
||||
}
|
||||
|
||||
func (srv *SummaryService) Summarize(from, to time.Time, user *models.User, filters *models.Filters) (*models.Summary, error) {
|
||||
@@ -217,7 +217,7 @@ func (srv *SummaryService) Summarize(from, to time.Time, user *models.User, filt
|
||||
NumHeartbeats: durations.TotalNumHeartbeats(),
|
||||
}
|
||||
|
||||
return summary.Sorted(), nil
|
||||
return summary.Sorted().InTZ(user.TZ()), nil
|
||||
}
|
||||
|
||||
// CRUD methods
|
||||
|
||||
Reference in New Issue
Block a user