app

package
v0.0.2 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	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) 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
	CreateUser(*domain.User) (*domain.User, error)
	GetUserByUsername(string) (*domain.User, error)
	GetUserByID(int) (*domain.User, error)
	GetUserCount() (int, error)

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

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

	// datasets
	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
	CreateObservation(*domain.Observation) (*domain.Observation, error)
	CreateOrUpdateObservation(*domain.Observation) (*domain.Observation, error)

	// correlations
	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