2020-11-08 12:12:49 +03:00
|
|
|
package repositories
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/muety/wakapi/models"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type IAliasRepository interface {
|
2021-01-21 02:26:52 +03:00
|
|
|
Insert(*models.Alias) (*models.Alias, error)
|
|
|
|
Delete(uint) error
|
|
|
|
DeleteBatch([]uint) error
|
2021-04-18 11:59:13 +03:00
|
|
|
GetAll() ([]*models.Alias, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetByUser(string) ([]*models.Alias, error)
|
2021-01-21 02:26:52 +03:00
|
|
|
GetByUserAndKey(string, string) ([]*models.Alias, error)
|
|
|
|
GetByUserAndKeyAndType(string, string, uint8) ([]*models.Alias, error)
|
|
|
|
GetByUserAndTypeAndValue(string, uint8, string) (*models.Alias, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type IHeartbeatRepository interface {
|
|
|
|
InsertBatch([]*models.Heartbeat) error
|
2021-04-18 11:59:13 +03:00
|
|
|
GetAll() ([]*models.Heartbeat, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetAllWithin(time.Time, time.Time, *models.User) ([]*models.Heartbeat, error)
|
2022-03-13 10:17:50 +03:00
|
|
|
GetAllWithinByFilters(time.Time, time.Time, *models.User, map[string][]string) ([]*models.Heartbeat, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetFirstByUsers() ([]*models.TimeByUser, error)
|
2021-02-13 13:23:58 +03:00
|
|
|
GetLastByUsers() ([]*models.TimeByUser, error)
|
2021-04-30 11:12:28 +03:00
|
|
|
GetLatestByUser(*models.User) (*models.Heartbeat, error)
|
2021-02-06 02:31:30 +03:00
|
|
|
GetLatestByOriginAndUser(string, *models.User) (*models.Heartbeat, error)
|
2022-03-19 12:30:32 +03:00
|
|
|
Count(bool) (int64, error)
|
2021-02-13 13:23:58 +03:00
|
|
|
CountByUser(*models.User) (int64, error)
|
|
|
|
CountByUsers([]*models.User) ([]*models.CountByUser, error)
|
2021-05-01 14:52:03 +03:00
|
|
|
GetEntitySetByUser(uint8, *models.User) ([]string, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
DeleteBefore(time.Time) error
|
2022-03-17 13:55:13 +03:00
|
|
|
DeleteByUser(*models.User) error
|
2022-12-01 22:26:03 +03:00
|
|
|
DeleteByUserBefore(*models.User, time.Time) error
|
2020-11-08 12:12:49 +03:00
|
|
|
}
|
|
|
|
|
2021-08-07 11:16:50 +03:00
|
|
|
type IDiagnosticsRepository interface {
|
|
|
|
Insert(diagnostics *models.Diagnostics) (*models.Diagnostics, error)
|
|
|
|
}
|
|
|
|
|
2020-11-08 12:12:49 +03:00
|
|
|
type IKeyValueRepository interface {
|
2021-04-18 11:59:13 +03:00
|
|
|
GetAll() ([]*models.KeyStringValue, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetString(string) (*models.KeyStringValue, error)
|
|
|
|
PutString(*models.KeyStringValue) error
|
|
|
|
DeleteString(string) error
|
2022-12-23 15:41:32 +03:00
|
|
|
Search(string) ([]*models.KeyStringValue, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type ILanguageMappingRepository interface {
|
2021-04-18 11:59:13 +03:00
|
|
|
GetAll() ([]*models.LanguageMapping, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetById(uint) (*models.LanguageMapping, error)
|
|
|
|
GetByUser(string) ([]*models.LanguageMapping, error)
|
|
|
|
Insert(*models.LanguageMapping) (*models.LanguageMapping, error)
|
|
|
|
Delete(uint) error
|
|
|
|
}
|
|
|
|
|
2021-06-11 21:59:34 +03:00
|
|
|
type IProjectLabelRepository interface {
|
|
|
|
GetAll() ([]*models.ProjectLabel, error)
|
|
|
|
GetById(uint) (*models.ProjectLabel, error)
|
|
|
|
GetByUser(string) ([]*models.ProjectLabel, error)
|
|
|
|
Insert(*models.ProjectLabel) (*models.ProjectLabel, error)
|
|
|
|
Delete(uint) error
|
|
|
|
}
|
|
|
|
|
2020-11-08 12:12:49 +03:00
|
|
|
type ISummaryRepository interface {
|
|
|
|
Insert(*models.Summary) error
|
2021-04-18 11:59:13 +03:00
|
|
|
GetAll() ([]*models.Summary, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetByUserWithin(*models.User, time.Time, time.Time) ([]*models.Summary, error)
|
|
|
|
GetLastByUser() ([]*models.TimeByUser, error)
|
|
|
|
DeleteByUser(string) error
|
2022-12-01 22:26:03 +03:00
|
|
|
DeleteByUserBefore(string, time.Time) error
|
2020-11-08 12:12:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type IUserRepository interface {
|
2022-12-30 15:14:24 +03:00
|
|
|
FindOne(user models.User) (*models.User, error)
|
2021-02-13 13:23:58 +03:00
|
|
|
GetByIds([]string) ([]*models.User, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetAll() ([]*models.User, error)
|
2022-10-04 00:52:22 +03:00
|
|
|
GetMany([]string) ([]*models.User, error)
|
2021-04-30 15:07:14 +03:00
|
|
|
GetAllByReports(bool) ([]*models.User, error)
|
2022-10-02 01:01:39 +03:00
|
|
|
GetAllByLeaderboard(bool) ([]*models.User, error)
|
2021-02-13 01:06:48 +03:00
|
|
|
GetByLoggedInAfter(time.Time) ([]*models.User, error)
|
2021-02-13 13:23:58 +03:00
|
|
|
GetByLastActiveAfter(time.Time) ([]*models.User, error)
|
2021-02-12 20:49:47 +03:00
|
|
|
Count() (int64, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
InsertOrGet(*models.User) (*models.User, bool, error)
|
|
|
|
Update(*models.User) (*models.User, error)
|
|
|
|
UpdateField(*models.User, string, interface{}) (*models.User, error)
|
2021-02-03 00:54:22 +03:00
|
|
|
Delete(*models.User) error
|
2020-11-08 12:12:49 +03:00
|
|
|
}
|
2022-10-02 01:01:39 +03:00
|
|
|
|
|
|
|
type ILeaderboardRepository interface {
|
|
|
|
InsertBatch([]*models.LeaderboardItem) error
|
2022-10-02 11:13:39 +03:00
|
|
|
CountAllByUser(string) (int64, error)
|
2022-10-19 19:28:30 +03:00
|
|
|
CountUsers() (int64, error)
|
2022-10-06 15:52:06 +03:00
|
|
|
DeleteByUser(string) error
|
2022-10-02 01:01:39 +03:00
|
|
|
DeleteByUserAndInterval(string, *models.IntervalKey) error
|
2022-10-20 09:33:12 +03:00
|
|
|
GetAllAggregatedByInterval(*models.IntervalKey, *uint8, int, int) ([]*models.LeaderboardItemRanked, error)
|
|
|
|
GetAggregatedByUserAndInterval(string, *models.IntervalKey, *uint8, int, int) ([]*models.LeaderboardItemRanked, error)
|
2022-10-02 01:01:39 +03:00
|
|
|
}
|