services

package
v0.0.0-...-b858a02 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableHeartbeat = "heartbeat"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregationJob

type AggregationJob struct {
	UserID string
	From   time.Time
	To     time.Time
}

type AggregationService

type AggregationService struct {
	Config           *models.Config
	Db               *gorm.DB
	UserService      *UserService
	SummaryService   *SummaryService
	HeartbeatService *HeartbeatService
}

func (*AggregationService) Init

func (srv *AggregationService) Init()

func (*AggregationService) Schedule

func (srv *AggregationService) Schedule()

Schedule a job to (re-)generate summaries every day shortly after midnight TODO: Make configurable

type AliasService

type AliasService struct {
	Config *models.Config
	Db     *gorm.DB
}

func (*AliasService) GetAliasOrDefault

func (srv *AliasService) GetAliasOrDefault(userId string, summaryType uint8, value string) (string, error)

func (*AliasService) Init

func (srv *AliasService) Init()

func (*AliasService) IsInitialized

func (src *AliasService) IsInitialized(userId string) bool

func (*AliasService) LoadUserAliases

func (srv *AliasService) LoadUserAliases(userId string) error

type HeartbeatService

type HeartbeatService struct {
	Config *models.Config
	Db     *gorm.DB
}

func (*HeartbeatService) CleanUp

func (srv *HeartbeatService) CleanUp() error

func (*HeartbeatService) DeleteBefore

func (srv *HeartbeatService) DeleteBefore(t time.Time) error

func (*HeartbeatService) GetAllWithin

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

func (*HeartbeatService) GetFirstUserHeartbeats

func (srv *HeartbeatService) GetFirstUserHeartbeats(userIds []string) ([]*models.Heartbeat, error)

Will return *models.Heartbeat object with only user_id and time fields filled

func (*HeartbeatService) Init

func (srv *HeartbeatService) Init()

func (*HeartbeatService) InsertBatch

func (srv *HeartbeatService) InsertBatch(heartbeats []*models.Heartbeat) error

func (*HeartbeatService) ScheduleCleanUp

func (srv *HeartbeatService) ScheduleCleanUp()

type Initializable

type Initializable interface {
	Init()
}

type Interval

type Interval struct {
	Start time.Time
	End   time.Time
}

type SummaryService

type SummaryService struct {
	Config           *models.Config
	Cache            *cache.Cache
	Db               *gorm.DB
	HeartbeatService *HeartbeatService
	AliasService     *AliasService
}

func (*SummaryService) Construct

func (srv *SummaryService) Construct(from, to time.Time, user *models.User, recompute bool) (*models.Summary, error)

func (*SummaryService) GetByUserWithin

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

func (*SummaryService) GetLatestByUser

func (srv *SummaryService) GetLatestByUser() ([]*models.Summary, error)

Will return *models.Summary objects with only user_id and to_time filled

func (*SummaryService) Init

func (srv *SummaryService) Init()

func (*SummaryService) Insert

func (srv *SummaryService) Insert(summary *models.Summary) error

type UserService

type UserService struct {
	Config *models.Config
	Db     *gorm.DB
}

func (*UserService) GetAll

func (srv *UserService) GetAll() ([]*models.User, error)

func (*UserService) GetUserById

func (srv *UserService) GetUserById(userId string) (*models.User, error)

func (*UserService) GetUserByKey

func (srv *UserService) GetUserByKey(key string) (*models.User, error)

func (*UserService) Init

func (srv *UserService) Init()

Jump to

Keyboard shortcuts

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