history

package
v5.5.9 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatHourMinute     = "15:04"            // FormatHeureMinute specifies the format for hour and minutes
	FormatDateHourMinute = "2006-01-02 15:04" // FormatDateHeureMinuteSeconde specifies the format for date, hour, minutes, and seconds
)

Variables

This section is empty.

Functions

func EvaluateExpressionFacts

func EvaluateExpressionFacts(expressionFacts []situation.ExpressionFact, data map[string]interface{}) map[string]interface{}

func ExtractHistoryDataSearch

func ExtractHistoryDataSearch(historySituations []HistorySituationsV4, historySituationFacts []HistorySituationFactsV4, historyFacts []HistoryFactsV4) search.QueryResult

func ExtractSituationData

func ExtractSituationData(situationID int64, situationInstanceID int64) (situation.Situation, map[string]string, error)

func ReplaceGlobals

func ReplaceGlobals(service HistoryService) func()

ReplaceGlobals affect a new service to the global service singleton.

Types

type FactResult added in v5.3.0

type FactResult struct {
	Value         int64  `json:"value"`
	FormattedTime string `json:"formattedTime" example:"2006-01-02 15:04:05"`
}

type GetFactHistory added in v5.3.0

type GetFactHistory struct {
	Results []FactResult `json:"results"`
}

type GetHistorySituationsOptions

type GetHistorySituationsOptions struct {
	SituationID         int64
	SituationInstanceID int64
	ParameterFilters    map[string]string
	DeleteBeforeTs      time.Time
	FromTS              time.Time
	ToTS                time.Time
}

type HistoryFactsBuilder

type HistoryFactsBuilder struct{}

func (HistoryFactsBuilder) Delete added in v5.3.0

func (builder HistoryFactsBuilder) Delete(ID int64) sq.DeleteBuilder

func (HistoryFactsBuilder) DeleteOrphans added in v5.2.2

func (builder HistoryFactsBuilder) DeleteOrphans() sq.DeleteBuilder

func (HistoryFactsBuilder) GetFactResultByDate added in v5.3.6

func (builder HistoryFactsBuilder) GetFactResultByDate(param ParamGetFactHistoryByDate) sq.SelectBuilder

func (HistoryFactsBuilder) GetHistoryFactLast

func (builder HistoryFactsBuilder) GetHistoryFactLast(situationID int64, instanceID int64, factID int64) sq.SelectBuilder

func (HistoryFactsBuilder) GetHistoryFacts

func (builder HistoryFactsBuilder) GetHistoryFacts(historyFactsIds []int64) sq.SelectBuilder

func (HistoryFactsBuilder) GetTodaysFactResultByParameters added in v5.3.0

func (builder HistoryFactsBuilder) GetTodaysFactResultByParameters(param ParamGetFactHistory) sq.SelectBuilder

func (HistoryFactsBuilder) Insert

func (builder HistoryFactsBuilder) Insert(history HistoryFactsV4, resultJSON []byte) sq.InsertBuilder

func (HistoryFactsBuilder) Update

func (builder HistoryFactsBuilder) Update(id int64, resultJSON []byte) sq.UpdateBuilder

type HistoryFactsQuerier

type HistoryFactsQuerier struct {
	Builder HistoryFactsBuilder
	// contains filtered or unexported fields
}

func (HistoryFactsQuerier) Delete added in v5.3.0

func (querier HistoryFactsQuerier) Delete(ID int64) error

func (HistoryFactsQuerier) Exec

func (querier HistoryFactsQuerier) Exec(builder sq.InsertBuilder) error

func (HistoryFactsQuerier) ExecDelete added in v5.2.2

func (querier HistoryFactsQuerier) ExecDelete(builder sq.DeleteBuilder) error

func (HistoryFactsQuerier) ExecUpdate added in v5.0.13

func (querier HistoryFactsQuerier) ExecUpdate(builder sq.UpdateBuilder) error

func (HistoryFactsQuerier) GetFactResultByDate added in v5.3.6

func (querier HistoryFactsQuerier) GetFactResultByDate(param ParamGetFactHistoryByDate) (GetFactHistory, error)

func (HistoryFactsQuerier) GetTodaysFactResultByParameters added in v5.3.0

func (querier HistoryFactsQuerier) GetTodaysFactResultByParameters(param ParamGetFactHistory) (GetFactHistory, error)

func (HistoryFactsQuerier) Insert

func (querier HistoryFactsQuerier) Insert(history HistoryFactsV4) (int64, error)

func (HistoryFactsQuerier) Query

func (querier HistoryFactsQuerier) Query(builder sq.SelectBuilder) ([]HistoryFactsV4, error)

func (*HistoryFactsQuerier) QueryGetSpecificFields added in v5.3.0

func (querier *HistoryFactsQuerier) QueryGetSpecificFields(builder sq.SelectBuilder, formatTime string) (GetFactHistory, error)

func (HistoryFactsQuerier) QueryOne

func (querier HistoryFactsQuerier) QueryOne(builder sq.SelectBuilder) (HistoryFactsV4, error)

func (HistoryFactsQuerier) QueryReturning

func (querier HistoryFactsQuerier) QueryReturning(builder sq.InsertBuilder) (int64, error)

func (HistoryFactsQuerier) Update added in v5.0.13

func (querier HistoryFactsQuerier) Update(history HistoryFactsV4) error

type HistoryFactsV4

type HistoryFactsV4 struct {
	ID                  int64
	FactID              int64
	FactName            string
	SituationID         int64
	SituationInstanceID int64
	Ts                  time.Time
	Result              reader.Item
}

type HistoryRecordV4

type HistoryRecordV4 struct {
	SituationID         int64
	SituationInstanceID int64
	Ts                  time.Time
	HistoryFacts        []HistoryFactsV4
	Parameters          map[string]string
	ExpressionFacts     map[string]interface{}
	EnableDependsOn     bool
	DependsOnParameters map[string]string
}

HistoryRecordV4 represents a single and unique situation history entry.

func (HistoryRecordV4) OverrideParameters

func (hr HistoryRecordV4) OverrideParameters(p map[string]string)

OverrideParameters overrides the parameters of the History Record.

type HistoryService

type HistoryService struct {
	HistorySituationsQuerier     HistorySituationsQuerier
	HistorySituationFactsQuerier HistorySituationFactsQuerier
	HistoryFactsQuerier          HistoryFactsQuerier
}

func New

func New(db *sqlx.DB) HistoryService

func S

func S() HistoryService

R is used to access the global service singleton.

func (HistoryService) CompactHistory added in v5.2.3

func (service HistoryService) CompactHistory(options GetHistorySituationsOptions, interval string) error

func (HistoryService) ExtractFactData

func (service HistoryService) ExtractFactData(situationID int64, instanceID int64, historyFactsNew []HistoryFactsV4, existingFactIDs []int64) ([]HistoryFactsV4, map[string]interface{}, error)

Flatten situation data (old and new facts + parameters).

func (HistoryService) GetHistoryFactsFromSituation

func (service HistoryService) GetHistoryFactsFromSituation(historySituations []HistorySituationsV4) ([]HistoryFactsV4, []HistorySituationFactsV4, error)

func (HistoryService) GetHistoryFactsFromSituationIds

func (service HistoryService) GetHistoryFactsFromSituationIds(historySituationsIds []int64) ([]HistoryFactsV4, []HistorySituationFactsV4, error)

func (HistoryService) GetHistorySituationsIdsByCustomInterval

func (service HistoryService) GetHistorySituationsIdsByCustomInterval(options GetHistorySituationsOptions, interval time.Duration, referenceDate time.Time) ([]HistorySituationsV4, error)

func (HistoryService) GetHistorySituationsIdsByStandardInterval

func (service HistoryService) GetHistorySituationsIdsByStandardInterval(options GetHistorySituationsOptions, interval string) ([]HistorySituationsV4, error)

func (HistoryService) GetHistorySituationsIdsLast

func (service HistoryService) GetHistorySituationsIdsLast(options GetHistorySituationsOptions) ([]HistorySituationsV4, error)

func (HistoryService) PurgeHistory added in v5.2.2

func (service HistoryService) PurgeHistory(options GetHistorySituationsOptions) error

type HistorySituationFactsBuilder

type HistorySituationFactsBuilder struct{}

func (HistorySituationFactsBuilder) DeleteHistoryFrom added in v5.2.2

func (builder HistorySituationFactsBuilder) DeleteHistoryFrom(situationHistoryQueryBuilder sq.SelectBuilder) sq.DeleteBuilder

func (HistorySituationFactsBuilder) GetHistorySituationFacts

func (builder HistorySituationFactsBuilder) GetHistorySituationFacts(historySituationsIds []int64) sq.SelectBuilder

func (HistorySituationFactsBuilder) InsertBulk

func (builder HistorySituationFactsBuilder) InsertBulk(historySituationFacts []HistorySituationFactsV4) sq.InsertBuilder

type HistorySituationFactsQuerier

type HistorySituationFactsQuerier struct {
	Builder HistorySituationFactsBuilder
	// contains filtered or unexported fields
}

func (HistorySituationFactsQuerier) ExecDelete added in v5.2.2

func (querier HistorySituationFactsQuerier) ExecDelete(builder sq.DeleteBuilder) error

func (HistorySituationFactsQuerier) Execute

func (querier HistorySituationFactsQuerier) Execute(builder sq.InsertBuilder) error

func (HistorySituationFactsQuerier) Query

type HistorySituationFactsV4

type HistorySituationFactsV4 struct {
	HistorySituationID int64
	HistoryFactID      int64
	FactID             int64
}

type HistorySituationsBuilder

type HistorySituationsBuilder struct{}

func (HistorySituationsBuilder) DeleteOrphans added in v5.2.2

func (builder HistorySituationsBuilder) DeleteOrphans() sq.DeleteBuilder

func (HistorySituationsBuilder) GetHistorySituationsDetails

func (builder HistorySituationsBuilder) GetHistorySituationsDetails(subQueryIds string, subQueryIdsArgs []interface{}) sq.SelectBuilder

func (HistorySituationsBuilder) GetHistorySituationsIdsBase

func (builder HistorySituationsBuilder) GetHistorySituationsIdsBase(options GetHistorySituationsOptions) sq.SelectBuilder

func (HistorySituationsBuilder) GetHistorySituationsIdsByCustomInterval

func (builder HistorySituationsBuilder) GetHistorySituationsIdsByCustomInterval(options GetHistorySituationsOptions, interval time.Duration, referenceDate time.Time) sq.SelectBuilder

func (HistorySituationsBuilder) GetHistorySituationsIdsByStandardInterval

func (builder HistorySituationsBuilder) GetHistorySituationsIdsByStandardInterval(options GetHistorySituationsOptions, interval string) sq.SelectBuilder

func (HistorySituationsBuilder) GetHistorySituationsIdsLast

func (builder HistorySituationsBuilder) GetHistorySituationsIdsLast(options GetHistorySituationsOptions) sq.SelectBuilder

func (HistorySituationsBuilder) GetLatestHistorySituation added in v5.3.4

func (builder HistorySituationsBuilder) GetLatestHistorySituation(situationID int64, situationInstanceID int64) sq.SelectBuilder

func (HistorySituationsBuilder) Insert

func (builder HistorySituationsBuilder) Insert(history HistorySituationsV4, parametersJSON []byte, expressionFactsJSON []byte, metadatasJSON []byte) sq.InsertBuilder

func (HistorySituationsBuilder) Update added in v5.0.13

func (builder HistorySituationsBuilder) Update(id int64, parametersJSON []byte, expressionFactsJSON []byte, metadatasJSON []byte) sq.UpdateBuilder

type HistorySituationsQuerier

type HistorySituationsQuerier struct {
	Builder HistorySituationsBuilder
	// contains filtered or unexported fields
}

func (HistorySituationsQuerier) ExecDelete added in v5.2.2

func (querier HistorySituationsQuerier) ExecDelete(builder sq.DeleteBuilder) error

func (HistorySituationsQuerier) ExecUpdate added in v5.0.13

func (querier HistorySituationsQuerier) ExecUpdate(builder sq.UpdateBuilder) error

func (HistorySituationsQuerier) GetLatestHistory added in v5.3.4

func (querier HistorySituationsQuerier) GetLatestHistory(situationID int64, situationInstanceID int64) (HistorySituationsV4, error)

func (HistorySituationsQuerier) Insert

func (querier HistorySituationsQuerier) Insert(history HistorySituationsV4) (int64, error)

func (HistorySituationsQuerier) Query

func (*HistorySituationsQuerier) QueryGetFieldsTsMetadatas added in v5.3.4

func (querier *HistorySituationsQuerier) QueryGetFieldsTsMetadatas(ctx context.Context, builder sq.SelectBuilder) (HistorySituationsV4, error)

func (HistorySituationsQuerier) QueryIDs

func (querier HistorySituationsQuerier) QueryIDs(builder sq.SelectBuilder) ([]int64, error)

func (HistorySituationsQuerier) QueryReturning

func (querier HistorySituationsQuerier) QueryReturning(builder sq.InsertBuilder) (int64, error)

func (HistorySituationsQuerier) Update added in v5.0.13

func (querier HistorySituationsQuerier) Update(history HistorySituationsV4) error

type HistorySituationsV4

type HistorySituationsV4 struct {
	ID                    int64
	SituationID           int64
	SituationName         string
	SituationInstanceID   int64
	SituationInstanceName string
	Ts                    time.Time
	Parameters            map[string]string
	ExpressionFacts       map[string]interface{}
	Metadatas             []models.MetaData
	Calendar              *calendar.Calendar
}

type ParamGetFactHistory added in v5.3.0

type ParamGetFactHistory struct {
	FactID              int64 `json:"factID"`
	SituationID         int64 `json:"situationId"`
	SituationInstanceID int64 `json:"situationInstanceId"`
}

func (ParamGetFactHistory) IsValid added in v5.3.0

func (param ParamGetFactHistory) IsValid() error

type ParamGetFactHistoryByDate added in v5.3.6

type ParamGetFactHistoryByDate struct {
	ParamGetFactHistory
	StartDate string `json:"startDate"` // Expected format: "2006-01-02 15:04:05"
	EndDate   string `json:"endDate"`   // Expected format: "2006-01-02 15:04:05"
}

func (ParamGetFactHistoryByDate) IsValid added in v5.3.6

func (p ParamGetFactHistoryByDate) IsValid() error

Jump to

Keyboard shortcuts

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