domain

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: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PearsonCorrelationType  = "pearson"
	SpearmanCorrelationType = "spearman"
	AutoCorrelationType     = "auto"

	GranularityDay   = "day"
	GranularityWeek  = "week"
	GranularityMonth = "month"

	ScaleTypeNumeric = "numeric"
	ScaleTypeOrdinal = "ordinal"
	ScaleTypeNominal = "nominal"
	ScaleTypeBinary  = "binary"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Correlation

type Correlation struct {
	ID          int
	Left        *Dataset
	Right       *Dataset
	Coef        float64 // correlation coef
	P           float64 // p-value
	R2          float64 // determination coef
	Type        string  // Pearson or whatever
	Granularity string
	CreateTime  time.Time
	UpdateTime  time.Time
}

Correlation is a corr value of a pair of Datasets

type CorrelationMatrix

type CorrelationMatrix struct {
	Header []CorrelationMatrixHeaderItem
	Body   [][]CorrelationMatrixBodyItem
}

CorrelationMatrix holds correlations of user datasets to be shown in the app.

type CorrelationMatrixBodyItem

type CorrelationMatrixBodyItem struct {
	CorrelationID int
	Coef          float64 // correlation coef
	P             float64 // p-value
	R2            float64 // determination coef
	Type          string  // Pearson or whatever
	UpdateTime    time.Time
}

CorrelationMatrixBodyItem holds a correlation on the matrix

type CorrelationMatrixHeaderItem

type CorrelationMatrixHeaderItem struct {
	IndicatorID    int
	DatasetID      int
	IndicatorTitle string
	DatasetShared  bool
}

CorrelationMatrixHeaderItem holds a matrix subject description

type CreateIndicatorArgs

type CreateIndicatorArgs struct {
	Username    string // TODO: change to ID
	Title       string
	Description string
	ScaleType   string
}

type CreateOrUpdateObservationArgs

type CreateOrUpdateObservationArgs struct {
	UserID      int
	IndicatorID int
	Value       float64
	Date        *time.Time
}

type Dataset

type Dataset struct {
	ID           int
	User         *User
	Indicator    *Indicator
	CreateTime   time.Time
	UpdateTime   time.Time
	Observations []*Observation
	Params       *DatasetParams
	Source       string // user input or external system
	Shared       bool   // if dataset can be shared between all users
}

Dataset is an intance of an Indicator populated by user data. Each User can have one Dataset for each Indicator

type DatasetAggregation

type DatasetAggregation struct {
	IncludeZeroValues bool `json:"includeZeroValues"` // use zero values in aggregations
}

DatasetAggregation holds params for aggregation

type DatasetParams

type DatasetParams struct {
	Style       DatasetStyle
	Aggregation DatasetAggregation
}

DatasetParams holds various dataset options

type DatasetStyle

type DatasetStyle struct {
	Color string `json:"color,omitempty"`
}

DatasetStyle holds dataset apperance params for site/app

type GetCorrelationArgs

type GetCorrelationArgs struct {
	ID               int
	UserID           int
	WithDatasets     bool
	WithObservations bool
	ObservationLimit int
}

type GetCorrelationMatrixArgs

type GetCorrelationMatrixArgs struct {
	UserID      int
	WithShared  bool
	Granularity string
}

type GetDatasetsArgs

type GetDatasetsArgs struct {
	// IndicatorID      *int
	UserID           int
	WithIndicator    bool
	WithUser         bool
	ObservationLimit int
	Granularity      string
	Filter           GetDatasetsArgsFilter
}

type GetDatasetsArgsFilter

type GetDatasetsArgsFilter struct {
	ID         []int
	WithShared bool
}

type GetIndicatorsArgs

type GetIndicatorsArgs struct {
	UserID           int
	WithDataset      bool
	ObservationLimit int
	Granularity      string
	Filter           GetIndicatorsArgsFilter
}

type GetIndicatorsArgsFilter

type GetIndicatorsArgsFilter struct {
	ID        []int
	Code      []string
	Title     []string
	Active    *bool
	BuiltIn   *bool
	AuthorID  *int
	ScaleType *string
	External  *bool // not accesible via API, only for intenal use
}

type Indicator

type Indicator struct {
	ID           int
	Code         string // unique code for external systems
	Title        string
	Description  string
	Active       bool // FIXME move to dataset?
	BuiltIn      bool // if Indicator is created by the service
	External     bool // if Indicator is populated by the user or external system
	Scale        *Scale
	Author       *User
	UserDataset  *Dataset           // dataset for a specific user
	ValueMapping map[float64]string // aliases for nomial and ordinal scales
	CreateTime   time.Time
	UpdateTime   time.Time
}

Indicator is a set of user-created data

type Observation

type Observation struct {
	ID          int
	Value       float64
	Dataset     *Dataset
	Date        *time.Time
	Granularity string
	CreateTime  time.Time
	UpdateTime  time.Time
}

Observation is a data point for an indicator

type Scale

type Scale struct {
	ID          int
	Type        string // numeric, ordinal or nomial
	Title       string
	Description string
}

Scale is a type of a scale for an Indicator

type UpdateAggregationsArgs

type UpdateAggregationsArgs struct {
	UserID    int
	DatasetID int
}

type UpdateCorrelationsArgs

type UpdateCorrelationsArgs struct {
	UserID      int
	WithShared  bool
	Granularity string
	Method      string // pearson, spearman or auto
}

type User

type User struct {
	ID           int // id is passed to domain model for simplicity
	Username     string
	Password     string
	PasswordHash string
	Email        string // TODO: add ent validation

}

User holds user data

type UserSettings

type UserSettings struct {
}

UserSettings holds user app/site preferences

Jump to

Keyboard shortcuts

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