repositories

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AliasRepository

type AliasRepository struct {
	// contains filtered or unexported fields
}

func NewAliasRepository

func NewAliasRepository(db *gorm.DB) *AliasRepository

func (*AliasRepository) Delete

func (r *AliasRepository) Delete(id uint) error

func (*AliasRepository) DeleteBatch

func (r *AliasRepository) DeleteBatch(ids []uint) error

func (*AliasRepository) GetAll

func (r *AliasRepository) GetAll() ([]*models.Alias, error)

func (*AliasRepository) GetByUser

func (r *AliasRepository) GetByUser(userId string) ([]*models.Alias, error)

func (*AliasRepository) GetByUserAndKey

func (r *AliasRepository) GetByUserAndKey(userId, key string) ([]*models.Alias, error)

func (*AliasRepository) GetByUserAndKeyAndType

func (r *AliasRepository) GetByUserAndKeyAndType(userId, key string, summaryType uint8) ([]*models.Alias, error)

func (*AliasRepository) GetByUserAndTypeAndValue

func (r *AliasRepository) GetByUserAndTypeAndValue(userId string, summaryType uint8, value string) (*models.Alias, error)

func (*AliasRepository) Insert

func (r *AliasRepository) Insert(alias *models.Alias) (*models.Alias, error)

type DiagnosticsRepository

type DiagnosticsRepository struct {
	// contains filtered or unexported fields
}

func NewDiagnosticsRepository

func NewDiagnosticsRepository(db *gorm.DB) *DiagnosticsRepository

func (*DiagnosticsRepository) Insert

func (r *DiagnosticsRepository) Insert(diagnostics *models.Diagnostics) (*models.Diagnostics, error)

type HeartbeatRepository

type HeartbeatRepository struct {
	// contains filtered or unexported fields
}

func NewHeartbeatRepository

func NewHeartbeatRepository(db *gorm.DB) *HeartbeatRepository

func (*HeartbeatRepository) Count

func (r *HeartbeatRepository) Count(approximate bool) (count int64, err error)

func (*HeartbeatRepository) CountByUser

func (r *HeartbeatRepository) CountByUser(user *models.User) (int64, error)

func (*HeartbeatRepository) CountByUsers

func (r *HeartbeatRepository) CountByUsers(users []*models.User) ([]*models.CountByUser, error)

func (*HeartbeatRepository) DeleteBefore

func (r *HeartbeatRepository) DeleteBefore(t time.Time) error

func (*HeartbeatRepository) DeleteByUser

func (r *HeartbeatRepository) DeleteByUser(user *models.User) error

func (*HeartbeatRepository) DeleteByUserBefore

func (r *HeartbeatRepository) DeleteByUserBefore(user *models.User, t time.Time) error

func (*HeartbeatRepository) GetAll

func (r *HeartbeatRepository) GetAll() ([]*models.Heartbeat, error)

Use with caution!!

func (*HeartbeatRepository) GetAllWithin

func (r *HeartbeatRepository) GetAllWithin(from, to time.Time, user *models.User) ([]*models.Heartbeat, error)

func (*HeartbeatRepository) GetAllWithinByFilters

func (r *HeartbeatRepository) GetAllWithinByFilters(from, to time.Time, user *models.User, filterMap map[string][]string) ([]*models.Heartbeat, error)

func (*HeartbeatRepository) GetEntitySetByUser

func (r *HeartbeatRepository) GetEntitySetByUser(entityType uint8, userId string) ([]string, error)

func (*HeartbeatRepository) GetFirstByUsers

func (r *HeartbeatRepository) GetFirstByUsers() ([]*models.TimeByUser, error)

func (*HeartbeatRepository) GetLastByUsers

func (r *HeartbeatRepository) GetLastByUsers() ([]*models.TimeByUser, error)

func (*HeartbeatRepository) GetLatestByFilters

func (r *HeartbeatRepository) GetLatestByFilters(user *models.User, filterMap map[string][]string) (*models.Heartbeat, error)

func (*HeartbeatRepository) GetLatestByOriginAndUser

func (r *HeartbeatRepository) GetLatestByOriginAndUser(origin string, user *models.User) (*models.Heartbeat, error)

func (*HeartbeatRepository) GetLatestByUser

func (r *HeartbeatRepository) GetLatestByUser(user *models.User) (*models.Heartbeat, error)

func (*HeartbeatRepository) GetUserProjectStats

func (r *HeartbeatRepository) GetUserProjectStats(user *models.User, from, to time.Time, limit, offset int) ([]*models.ProjectStats, error)

func (*HeartbeatRepository) InsertBatch

func (r *HeartbeatRepository) InsertBatch(heartbeats []*models.Heartbeat) error

type IAliasRepository

type IAliasRepository interface {
	Insert(*models.Alias) (*models.Alias, error)
	Delete(uint) error
	DeleteBatch([]uint) error
	GetAll() ([]*models.Alias, error)
	GetByUser(string) ([]*models.Alias, error)
	GetByUserAndKey(string, string) ([]*models.Alias, error)
	GetByUserAndKeyAndType(string, string, uint8) ([]*models.Alias, error)
	GetByUserAndTypeAndValue(string, uint8, string) (*models.Alias, error)
}

type IDiagnosticsRepository

type IDiagnosticsRepository interface {
	Insert(diagnostics *models.Diagnostics) (*models.Diagnostics, error)
}

type IHeartbeatRepository

type IHeartbeatRepository interface {
	InsertBatch([]*models.Heartbeat) error
	GetAll() ([]*models.Heartbeat, error)
	GetAllWithin(time.Time, time.Time, *models.User) ([]*models.Heartbeat, error)
	GetAllWithinByFilters(time.Time, time.Time, *models.User, map[string][]string) ([]*models.Heartbeat, error)
	GetLatestByFilters(*models.User, map[string][]string) (*models.Heartbeat, error)
	GetFirstByUsers() ([]*models.TimeByUser, error)
	GetLastByUsers() ([]*models.TimeByUser, error)
	GetLatestByUser(*models.User) (*models.Heartbeat, error)
	GetLatestByOriginAndUser(string, *models.User) (*models.Heartbeat, error)
	Count(bool) (int64, error)
	CountByUser(*models.User) (int64, error)
	CountByUsers([]*models.User) ([]*models.CountByUser, error)
	GetEntitySetByUser(uint8, string) ([]string, error)
	DeleteBefore(time.Time) error
	DeleteByUser(*models.User) error
	DeleteByUserBefore(*models.User, time.Time) error
	GetUserProjectStats(*models.User, time.Time, time.Time, int, int) ([]*models.ProjectStats, error)
}

type IKeyValueRepository

type IKeyValueRepository interface {
	GetAll() ([]*models.KeyStringValue, error)
	GetString(string) (*models.KeyStringValue, error)
	PutString(*models.KeyStringValue) error
	DeleteString(string) error
	Search(string) ([]*models.KeyStringValue, error)
}

type ILanguageMappingRepository

type ILanguageMappingRepository interface {
	GetAll() ([]*models.LanguageMapping, error)
	GetById(uint) (*models.LanguageMapping, error)
	GetByUser(string) ([]*models.LanguageMapping, error)
	Insert(*models.LanguageMapping) (*models.LanguageMapping, error)
	Delete(uint) error
}

type ILeaderboardRepository

type ILeaderboardRepository interface {
	InsertBatch([]*models.LeaderboardItem) error
	CountAllByUser(string) (int64, error)
	CountUsers(bool) (int64, error)
	DeleteByUser(string) error
	DeleteByUserAndInterval(string, *models.IntervalKey) error
	GetAllAggregatedByInterval(*models.IntervalKey, *uint8, int, int) ([]*models.LeaderboardItemRanked, error)
	GetAggregatedByUserAndInterval(string, *models.IntervalKey, *uint8, int, int) ([]*models.LeaderboardItemRanked, error)
}

type IProjectLabelRepository

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
}

type ISummaryRepository

type ISummaryRepository interface {
	Insert(*models.Summary) error
	GetAll() ([]*models.Summary, error)
	GetByUserWithin(*models.User, time.Time, time.Time) ([]*models.Summary, error)
	GetLastByUser() ([]*models.TimeByUser, error)
	DeleteByUser(string) error
	DeleteByUserBefore(string, time.Time) error
}

type IUserRepository

type IUserRepository interface {
	FindOne(user models.User) (*models.User, error)
	GetByIds([]string) ([]*models.User, error)
	GetAll() ([]*models.User, error)
	GetMany([]string) ([]*models.User, error)
	GetAllByReports(bool) ([]*models.User, error)
	GetAllByLeaderboard(bool) ([]*models.User, error)
	GetByLoggedInBefore(time.Time) ([]*models.User, error)
	GetByLoggedInAfter(time.Time) ([]*models.User, error)
	GetByLastActiveAfter(time.Time) ([]*models.User, error)
	Count() (int64, error)
	InsertOrGet(*models.User) (*models.User, bool, error)
	Update(*models.User) (*models.User, error)
	UpdateField(*models.User, string, interface{}) (*models.User, error)
	Delete(*models.User) error
}

type KeyValueRepository

type KeyValueRepository struct {
	// contains filtered or unexported fields
}

func NewKeyValueRepository

func NewKeyValueRepository(db *gorm.DB) *KeyValueRepository

func (*KeyValueRepository) DeleteString

func (r *KeyValueRepository) DeleteString(key string) error

func (*KeyValueRepository) GetAll

func (r *KeyValueRepository) GetAll() ([]*models.KeyStringValue, error)

func (*KeyValueRepository) GetString

func (r *KeyValueRepository) GetString(key string) (*models.KeyStringValue, error)

func (*KeyValueRepository) PutString

func (r *KeyValueRepository) PutString(kv *models.KeyStringValue) error

func (*KeyValueRepository) Search

func (r *KeyValueRepository) Search(like string) ([]*models.KeyStringValue, error)

type LanguageMappingRepository

type LanguageMappingRepository struct {
	// contains filtered or unexported fields
}

func NewLanguageMappingRepository

func NewLanguageMappingRepository(db *gorm.DB) *LanguageMappingRepository

func (*LanguageMappingRepository) Delete

func (r *LanguageMappingRepository) Delete(id uint) error

func (*LanguageMappingRepository) GetAll

func (*LanguageMappingRepository) GetById

func (*LanguageMappingRepository) GetByUser

func (r *LanguageMappingRepository) GetByUser(userId string) ([]*models.LanguageMapping, error)

func (*LanguageMappingRepository) Insert

type LeaderboardRepository

type LeaderboardRepository struct {
	// contains filtered or unexported fields
}

func NewLeaderboardRepository

func NewLeaderboardRepository(db *gorm.DB) *LeaderboardRepository

func (*LeaderboardRepository) CountAllByUser

func (r *LeaderboardRepository) CountAllByUser(userId string) (int64, error)

func (*LeaderboardRepository) CountUsers

func (r *LeaderboardRepository) CountUsers(excludeZero bool) (int64, error)

func (*LeaderboardRepository) DeleteByUser

func (r *LeaderboardRepository) DeleteByUser(userId string) error

func (*LeaderboardRepository) DeleteByUserAndInterval

func (r *LeaderboardRepository) DeleteByUserAndInterval(userId string, key *models.IntervalKey) error

func (*LeaderboardRepository) GetAggregatedByUserAndInterval

func (r *LeaderboardRepository) GetAggregatedByUserAndInterval(userId string, key *models.IntervalKey, by *uint8, limit, skip int) ([]*models.LeaderboardItemRanked, error)

func (*LeaderboardRepository) GetAllAggregatedByInterval

func (r *LeaderboardRepository) GetAllAggregatedByInterval(key *models.IntervalKey, by *uint8, limit, skip int) ([]*models.LeaderboardItemRanked, error)

func (*LeaderboardRepository) InsertBatch

func (r *LeaderboardRepository) InsertBatch(items []*models.LeaderboardItem) error

type MetricsRepository

type MetricsRepository struct {
	// contains filtered or unexported fields
}

func NewMetricsRepository

func NewMetricsRepository(db *gorm.DB) *MetricsRepository

func (*MetricsRepository) GetDatabaseSize

func (srv *MetricsRepository) GetDatabaseSize() (size int64, err error)

type ProjectLabelRepository

type ProjectLabelRepository struct {
	// contains filtered or unexported fields
}

func NewProjectLabelRepository

func NewProjectLabelRepository(db *gorm.DB) *ProjectLabelRepository

func (*ProjectLabelRepository) Delete

func (r *ProjectLabelRepository) Delete(id uint) error

func (*ProjectLabelRepository) GetAll

func (r *ProjectLabelRepository) GetAll() ([]*models.ProjectLabel, error)

func (*ProjectLabelRepository) GetById

func (*ProjectLabelRepository) GetByUser

func (r *ProjectLabelRepository) GetByUser(userId string) ([]*models.ProjectLabel, error)

func (*ProjectLabelRepository) Insert

type SummaryRepository

type SummaryRepository struct {
	// contains filtered or unexported fields
}

func NewSummaryRepository

func NewSummaryRepository(db *gorm.DB) *SummaryRepository

func (*SummaryRepository) DeleteByUser

func (r *SummaryRepository) DeleteByUser(userId string) error

func (*SummaryRepository) DeleteByUserBefore

func (r *SummaryRepository) DeleteByUserBefore(userId string, t time.Time) error

func (*SummaryRepository) GetAll

func (r *SummaryRepository) GetAll() ([]*models.Summary, error)

func (*SummaryRepository) GetByUserWithin

func (r *SummaryRepository) GetByUserWithin(user *models.User, from, to time.Time) ([]*models.Summary, error)

func (*SummaryRepository) GetLastByUser

func (r *SummaryRepository) GetLastByUser() ([]*models.TimeByUser, error)

func (*SummaryRepository) Insert

func (r *SummaryRepository) Insert(summary *models.Summary) error

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

func NewUserRepository

func NewUserRepository(db *gorm.DB) *UserRepository

func (*UserRepository) Count

func (r *UserRepository) Count() (int64, error)

func (*UserRepository) Delete

func (r *UserRepository) Delete(user *models.User) error

func (*UserRepository) FindOne

func (r *UserRepository) FindOne(attributes models.User) (*models.User, error)

func (*UserRepository) GetAll

func (r *UserRepository) GetAll() ([]*models.User, error)

func (*UserRepository) GetAllByLeaderboard

func (r *UserRepository) GetAllByLeaderboard(leaderboardEnabled bool) ([]*models.User, error)

func (*UserRepository) GetAllByReports

func (r *UserRepository) GetAllByReports(reportsEnabled bool) ([]*models.User, error)

func (*UserRepository) GetByIds

func (r *UserRepository) GetByIds(userIds []string) ([]*models.User, error)

func (*UserRepository) GetByLastActiveAfter

func (r *UserRepository) GetByLastActiveAfter(t time.Time) ([]*models.User, error)

Returns a list of user ids, whose last heartbeat is not older than t NOTE: Only ID field will be populated

func (*UserRepository) GetByLoggedInAfter

func (r *UserRepository) GetByLoggedInAfter(t time.Time) ([]*models.User, error)

func (*UserRepository) GetByLoggedInBefore

func (r *UserRepository) GetByLoggedInBefore(t time.Time) ([]*models.User, error)

func (*UserRepository) GetMany

func (r *UserRepository) GetMany(ids []string) ([]*models.User, error)

func (*UserRepository) InsertOrGet

func (r *UserRepository) InsertOrGet(user *models.User) (*models.User, bool, error)

func (*UserRepository) Update

func (r *UserRepository) Update(user *models.User) (*models.User, error)

func (*UserRepository) UpdateField

func (r *UserRepository) UpdateField(user *models.User, key string, value interface{}) (*models.User, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL