app

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Cron     *cron.Cron
	Channels *Channels
	// contains filtered or unexported fields
}

App combines services and holds business logic

func NewApp

func NewApp(
	cfg configs.Config,
	logger *logger.Logger,
	repo Repository,
) (*App, error)

func (*App) CreateIndicator

func (a *App) CreateIndicator(args domain.CreateIndicatorArgs) error

func (*App) CreateOrUpdateObservation

func (a *App) CreateOrUpdateObservation(args domain.CreateOrUpdateObservationArgs) error

CreateOrUpdateObservation checks if there is a dataset for user/indicator. If none, creates one and adds observation to it, otherwise adds to existing dataset.

func (*App) CreateUser

func (a *App) CreateUser(u *domain.User) error

func (*App) GetCorrelation

func (a *App) GetCorrelation(args domain.GetCorrelationArgs) (*domain.Correlation, error)

func (*App) GetCorrelationMatrix

func (a *App) GetCorrelationMatrix(args domain.GetCorrelationMatrixArgs) (*domain.CorrelationMatrix, error)

func (*App) GetIndicators

func (a *App) GetIndicators(args domain.GetIndicatorsArgs) ([]*domain.Indicator, error)

func (*App) GetScaleByType

func (a *App) GetScaleByType(scaleType string) (*domain.Scale, error)

func (*App) GetUser

func (a *App) GetUser(u *domain.User) (*domain.User, error)

func (*App) GetUserToken

func (a *App) GetUserToken(u *domain.User) (string, error)

func (*App) ServiceStats added in v0.0.5

func (a *App) ServiceStats() (*domain.ServiceStats, error)

func (*App) UpdateAggregations

func (a *App) UpdateAggregations(args domain.UpdateAggregationsArgs) error

func (*App) UpdateCorrelations

func (a *App) UpdateCorrelations(args domain.UpdateCorrelationsArgs) error

func (*App) ValidateUserPassword

func (a *App) ValidateUserPassword(u *domain.User) (bool, error)

type Cache

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

Cache stores data loaded on app start

type Channels

type Channels struct {
	UpdateUserCorrelationsChan    chan domain.UpdateCorrelationsArgs
	UpdateDatasetAggregationsChan chan domain.UpdateAggregationsArgs
}

Channels holds app channels for async jobs

type Repository

type Repository interface {
	// users
	UserCount() (int, error)
	CreateUser(*domain.User) (*domain.User, error)
	GetUserByUsername(string) (*domain.User, error)
	GetUserByID(int) (*domain.User, error)
	GetUserCount() (int, error)

	// indicators
	IndicatorCount() (int, error)
	CreateIndicator(*domain.Indicator) (*domain.Indicator, error)
	GetIndicatorByID(int) (*domain.Indicator, error)
	GetIndicators(domain.GetIndicatorsArgs) ([]*domain.Indicator, error)

	// scales
	ScaleCount() (int, error)
	GetScales() ([]*domain.Scale, error)
	GetScaleByType(string) (*domain.Scale, error)
	CreateScale(domain.Scale) (*domain.Scale, error)

	// datasets
	DatasetCount() (int, error)
	CreateDataset(*domain.Dataset) (*domain.Dataset, error)
	GetDatasetByID(id int, observationsLimit int, granularity string) (*domain.Dataset, error)
	GetUserIndicatorDataset(*domain.User, *domain.Indicator) (*domain.Dataset, error)
	GetOrCreateUserIndicatorDataset(*domain.User, *domain.Indicator) (*domain.Dataset, error)
	GetUserDatasets(userID int, withShared bool, observationsLimit int, granularity string) ([]*domain.Dataset, error) // to be deprecated
	GetDatasets(domain.GetDatasetsArgs) ([]*domain.Dataset, error)

	// observations
	ObservationCount() (int, error)
	CreateObservation(*domain.Observation) (*domain.Observation, error)
	CreateOrUpdateObservation(*domain.Observation) (*domain.Observation, error)

	// correlations
	CorrelationCount() (int, error)
	CreateOrUpdateCorrelation(*domain.Correlation) (*domain.Correlation, error)
	GetUserCorrelations(userID int, granularity string) ([]*domain.Correlation, error)
	GetCorrelation(domain.GetCorrelationArgs) (*domain.Correlation, error)
}

Repository stores data

Jump to

Keyboard shortcuts

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