feat: extend equipment and workout models with service tracking
This commit is contained in:
33
internal/stats/service.go
Normal file
33
internal/stats/service.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package stats
|
||||
|
||||
type Service struct {
|
||||
repo *Repository
|
||||
}
|
||||
|
||||
func NewService() *Service {
|
||||
return &Service{
|
||||
repo: NewRepository(),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) GetSummary(userID uint) (*Summary, error) {
|
||||
return s.repo.GetSummary(userID)
|
||||
}
|
||||
|
||||
func (s *Service) GetWeeklyStats(userID uint, weeks int) ([]PeriodStats, error) {
|
||||
if weeks <= 0 || weeks > 52 {
|
||||
weeks = 12
|
||||
}
|
||||
return s.repo.GetWeeklyStats(userID, weeks)
|
||||
}
|
||||
|
||||
func (s *Service) GetMonthlyStats(userID uint, months int) ([]PeriodStats, error) {
|
||||
if months <= 0 || months > 24 {
|
||||
months = 12
|
||||
}
|
||||
return s.repo.GetMonthlyStats(userID, months)
|
||||
}
|
||||
|
||||
func (s *Service) GetPersonalBests(userID uint) ([]PersonalBest, error) {
|
||||
return s.repo.GetPersonalBests(userID)
|
||||
}
|
||||
Reference in New Issue
Block a user