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

refactor: replace most custom date util functions by lancet ones

refactor: add precision mode to missing intervals function
This commit is contained in:
Ferdinand Mütsch
2022-03-25 12:48:56 +01:00
parent 8a731a252a
commit 5aae18e241
12 changed files with 608 additions and 723 deletions

View File

@@ -2,6 +2,7 @@ package services
import (
"fmt"
"github.com/duke-git/lancet/v2/datetime"
"github.com/emvi/logbuch"
"github.com/leandro-lugaresi/hub"
"github.com/muety/wakapi/config"
@@ -100,9 +101,9 @@ func (srv *UserService) GetAllByReports(reportsEnabled bool) ([]*models.User, er
}
func (srv *UserService) GetActive(exact bool) ([]*models.User, error) {
minDate := time.Now().Add(-24 * time.Hour * time.Duration(srv.config.App.InactiveDays))
minDate := time.Now().AddDate(0, 0, -1*srv.config.App.InactiveDays)
if !exact {
minDate = utils.FloorDateHour(minDate)
minDate = datetime.BeginOfHour(minDate)
}
cacheKey := fmt.Sprintf("%s--active", minDate.String())