domain

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: AGPL-3.0 Imports: 3 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
	ValueMapping map[string]string
	ValueParams  *IndicatorValueParams
}

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 Dictionary added in v0.0.8

type Dictionary struct {
	ID          int    `json:"id"`
	Code        string `json:"code"`
	Description string `json:"description"`
}

Dictionary holds dictionaries

func (*Dictionary) JSONString added in v0.0.8

func (d *Dictionary) JSONString() string

type DictionaryEntry added in v0.0.8

type DictionaryEntry struct {
	DictionaryID int    `json:"dictionaryId"`
	ID           int    `json:"id"`
	Code         string `json:"code"`
	Description  string `json:"description"`
}

DictionaryEntry holds entry of dictionary

func (*DictionaryEntry) JSONString added in v0.0.8

func (e *DictionaryEntry) JSONString() string

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                   `json:"id"`
	Code         string                `json:"code"` // unique code for external systems
	Title        string                `json:"title"`
	Description  string                `json:"description"`
	Active       bool                  `json:"active"`  // FIXME move to dataset?
	BuiltIn      bool                  `json:"builtIn"` // if Indicator is created by the service
	External     bool                  `json:"extrnal"` // if Indicator is populated by the user or external system
	Scale        *Scale                `json:"scale"`
	Author       *User                 `json:"author"`
	UserDataset  *Dataset              `json:"userDataset"`  // dataset for a specific user
	ValueMapping map[string]string     `json:"valueMapping"` // aliases for nomial and ordinal scales
	ValueParams  *IndicatorValueParams `json:"valueParams"`
	CreateTime   time.Time             `json:"createTime"`
	UpdateTime   time.Time             `json:"updateTime"`
}

Indicator is a set of user-created data

func (*Indicator) JSONString added in v0.0.7

func (i *Indicator) JSONString() string

func (*Indicator) Validate added in v0.0.9

func (i *Indicator) Validate() error

type IndicatorValueParams added in v0.0.8

type IndicatorValueParams struct {
	Default float64 `json:"default"`
	Min     float64 `json:"min"`
	Max     float64 `json:"max"`
	Step    float64 `json:"step"`
}

IndicatorValueParams holds rules for indicator values

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    `json:"id"`
	Type        string `json:"type"` // numeric, ordinal or nomial
	Title       string `json:"title"`
	Description string `json:"description"`
}

Scale is a type of a scale for an Indicator

func (*Scale) JSONString added in v0.0.7

func (s *Scale) JSONString() string

type ServiceStats added in v0.0.5

type ServiceStats struct {
	Users        int `json:"users,omitempty"`
	Scales       int `json:"scales,omitempty"`
	Indicators   int `json:"indicators,omitempty"`
	Datasets     int `json:"datasets,omitempty"`
	Observations int `json:"observations,omitempty"`
	Correlations int `json:"correlations,omitempty"`
}

ServiceStats struct holds service stats

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 UpdateIndicatorArgs added in v0.0.8

type UpdateIndicatorArgs struct {
	ID             int // immutable, only for getting indicator
	UserID         int
	Title          string
	Description    string
	Active         bool
	ValueMapping   map[string]string
	ValueParams    *IndicatorValueParams
	UpdateBuiltins bool
}

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