2020-11-08 12:12:49 +03:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/muety/wakapi/models"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type IAggregationService interface {
|
|
|
|
Schedule()
|
|
|
|
Run(map[string]bool) error
|
|
|
|
}
|
|
|
|
|
2021-01-17 11:24:09 +03:00
|
|
|
type IMiscService interface {
|
|
|
|
ScheduleCountTotalTime()
|
|
|
|
}
|
|
|
|
|
2020-11-08 12:12:49 +03:00
|
|
|
type IAliasService interface {
|
2021-01-21 02:26:52 +03:00
|
|
|
Create(*models.Alias) (*models.Alias, error)
|
|
|
|
Delete(*models.Alias) error
|
|
|
|
DeleteMulti([]*models.Alias) error
|
2020-11-08 12:12:49 +03:00
|
|
|
IsInitialized(string) bool
|
2021-01-21 02:26:52 +03:00
|
|
|
InitializeUser(string) error
|
|
|
|
GetByUser(string) ([]*models.Alias, error)
|
|
|
|
GetByUserAndKeyAndType(string, string, uint8) ([]*models.Alias, error)
|
|
|
|
GetAliasOrDefault(string, uint8, string) (string, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type IHeartbeatService interface {
|
|
|
|
InsertBatch([]*models.Heartbeat) error
|
|
|
|
GetAllWithin(time.Time, time.Time, *models.User) ([]*models.Heartbeat, error)
|
|
|
|
GetFirstByUsers() ([]*models.TimeByUser, error)
|
|
|
|
DeleteBefore(time.Time) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type IKeyValueService interface {
|
|
|
|
GetString(string) (*models.KeyStringValue, error)
|
|
|
|
PutString(*models.KeyStringValue) error
|
|
|
|
DeleteString(string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type ILanguageMappingService interface {
|
|
|
|
GetById(uint) (*models.LanguageMapping, error)
|
|
|
|
GetByUser(string) ([]*models.LanguageMapping, error)
|
|
|
|
ResolveByUser(string) (map[string]string, error)
|
|
|
|
Create(*models.LanguageMapping) (*models.LanguageMapping, error)
|
|
|
|
Delete(mapping *models.LanguageMapping) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type ISummaryService interface {
|
|
|
|
Aliased(time.Time, time.Time, *models.User, SummaryRetriever) (*models.Summary, error)
|
|
|
|
Retrieve(time.Time, time.Time, *models.User) (*models.Summary, error)
|
|
|
|
Summarize(time.Time, time.Time, *models.User) (*models.Summary, error)
|
|
|
|
GetLatestByUser() ([]*models.TimeByUser, error)
|
|
|
|
DeleteByUser(string) error
|
|
|
|
Insert(*models.Summary) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type IUserService interface {
|
|
|
|
GetUserById(string) (*models.User, error)
|
|
|
|
GetUserByKey(string) (*models.User, error)
|
|
|
|
GetAll() ([]*models.User, error)
|
|
|
|
CreateOrGet(*models.Signup) (*models.User, bool, error)
|
|
|
|
Update(*models.User) (*models.User, error)
|
|
|
|
ResetApiKey(*models.User) (*models.User, error)
|
|
|
|
ToggleBadges(*models.User) (*models.User, error)
|
2021-01-22 01:26:50 +03:00
|
|
|
SetWakatimeApiKey(*models.User, string) (*models.User, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
MigrateMd5Password(*models.User, *models.Login) (*models.User, error)
|
|
|
|
}
|