sqlstore

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const MySQLCharset = "DEFAULT CHARACTER SET utf8mb4"

Variables

This section is empty.

Functions

func GetTopPlaybooksInsightsListWithPagination added in v1.32.0

func GetTopPlaybooksInsightsListWithPagination(playbooks []*app.PlaybookInsight, limit int) *app.PlaybooksInsightsList

GetTopPlaybooksInsightsListWithPagination returns a page given a list of PlaybooksInsight assumed to be sorted by Runs(score). Returns a PlaybooksInsightsList.

func InsertPlaybook added in v1.34.0

func InsertPlaybook(sqlStore *SQLStore, playbook map[string]interface{}) error

func InsertPost added in v1.34.0

func InsertPost(sqlStore *SQLStore, id string, createdAt int64) error

func InsertRun added in v1.34.0

func InsertRun(sqlStore *SQLStore, run map[string]interface{}) error

func InsertStatusPost added in v1.34.0

func InsertStatusPost(sqlStore *SQLStore, incidentID, postID string) error

func LatestVersion

func LatestVersion() semver.Version

func NewCategoryStore added in v1.31.0

func NewCategoryStore(pluginAPI PluginAPIClient, sqlStore *SQLStore) app.CategoryStore

func NewChannelActionStore added in v1.26.0

func NewChannelActionStore(pluginAPI PluginAPIClient, sqlStore *SQLStore) app.ChannelActionStore

NewPlaybookStore creates a new store for playbook service.

func NewPlaybookRunStore

func NewPlaybookRunStore(pluginAPI PluginAPIClient, sqlStore *SQLStore) app.PlaybookRunStore

NewPlaybookRunStore creates a new store for playbook run ServiceImpl.

func NewPlaybookStore

func NewPlaybookStore(pluginAPI PluginAPIClient, sqlStore *SQLStore) app.PlaybookStore

NewPlaybookStore creates a new store for playbook service.

func NewUserInfoStore

func NewUserInfoStore(sqlStore *SQLStore) app.UserInfoStore

Types

type ConfigurationAPI

type ConfigurationAPI interface {
	GetConfig() *model.Config
}

type ConstraintsInfo added in v1.37.0

type ConstraintsInfo struct {
	ConstraintName string
	TableName      string
	ConstraintType string
}

type IndexInfo added in v1.32.0

type IndexInfo struct {
	TableName string
	IndexName string

	// Postgres specific field
	IndexDef string

	// MySQL specific fields
	ColumnName string
}

type KVAPI

type KVAPI interface {
	Get(key string, out interface{}) error
}

KVAPI is the key value store interface for the pluginkv stores. It is implemented by mattermost-plugin-api/Client.KV, or by the mock KVAPI.

type Migration

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

type PluginAPIClient

type PluginAPIClient struct {
	Store         StoreAPI
	KV            KVAPI
	Configuration ConfigurationAPI
}

PluginAPIClient is the struct combining the interfaces defined above, which is everything from pluginapi that the store currently uses.

func NewClient

func NewClient(api *pluginapi.Client) PluginAPIClient

NewClient receives a pluginapi.Client and returns the PluginAPIClient, which is what the store will use to access pluginapi.Client.

type SQLStore

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

func New

func New(pluginAPI PluginAPIClient, scheduler app.JobOnceScheduler) (*SQLStore, error)

New constructs a new instance of SQLStore.

func (*SQLStore) GetCurrentVersion

func (sqlStore *SQLStore) GetCurrentVersion() (semver.Version, error)

func (*SQLStore) RunMigrations

func (sqlStore *SQLStore) RunMigrations() error

RunMigrations will run the migrations (if any). The caller should hold a cluster mutex if there is a danger of this being run on multiple servers at once.

func (*SQLStore) SetCurrentVersion

func (sqlStore *SQLStore) SetCurrentVersion(e queryExecer, currentVersion semver.Version) error

type StatsFilters

type StatsFilters struct {
	TeamID     string
	PlaybookID string
}

type StatsStore

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

func NewStatsStore

func NewStatsStore(pluginAPI PluginAPIClient, sqlStore *SQLStore) *StatsStore

func (*StatsStore) ActiveParticipantsPerDayLastXDays

func (s *StatsStore) ActiveParticipantsPerDayLastXDays(x int, filters *StatsFilters) ([]int, [][]int64)

ActiveParticipantsPerDayLastXDays returns the number of active participants per day for the last X days. Returns data in order of oldest day to most recent day.

func (*StatsStore) ActiveRunsPerDayLastXDays

func (s *StatsStore) ActiveRunsPerDayLastXDays(x int, filters *StatsFilters) ([]int, [][]int64)

ActiveRunsPerDayLastXDays returns the number of active runs per day for the last X days. Returns data in order of oldest day to most recent day.

func (*StatsStore) MetricOverallAverage

func (s *StatsStore) MetricOverallAverage(filters StatsFilters) []null.Int

MetricOverallAverage for a specific playbook returns a list that contains an average value for each metric. Only published metrics values are included. Returns empty list when Playbook doesn't have configured metrics If for some metrics there are no published values, the corresponding element will be nil in the resulting slice

func (*StatsStore) MetricRollingAverageAndChange

func (s *StatsStore) MetricRollingAverageAndChange(x int, filters StatsFilters) (metricRollingAverage []null.Int, metricRollingAverageChange []null.Int)

MetricRollingAverageAndChange for each metric returns average of last `x` published values and change with comparison to the previous period returns empty list if the Playbook doesn't have metrics If for some metrics there are no published values, the corresponding element will be nil in the resulting slice

func (*StatsStore) MetricRollingValuesLastXRuns

func (s *StatsStore) MetricRollingValuesLastXRuns(x int, offset int, filters StatsFilters) ([][]int64, []string)

MetricRollingValuesLastXRuns for each metric returns list of last `x` published values, starting from `offset` first element in the list is most recent. And returns the names of the last `x` runs. Returns empty list if Playbook doesn't have metrics. If for some metrics there are no published values, the corresponding slice will be nil in the resulting slice

func (*StatsStore) MetricValueRange

func (s *StatsStore) MetricValueRange(filters StatsFilters) [][]int64

MetricValueRange returns min and max values for each metric Only published metrics are included. If there are no configured metrics, returns an empty list If for some metrics there are no published values, the corresponding slice will be nil in the resulting slice

func (*StatsStore) MovingWindowQueryActive

func (s *StatsStore) MovingWindowQueryActive(query sq.SelectBuilder, numDays int) ([]int, error)

Not efficient. One query per day.

func (*StatsStore) RunsFinishedBetweenDays

func (s *StatsStore) RunsFinishedBetweenDays(filters *StatsFilters, startDay, endDay int) int

RunsFinishedBetweenDays are calculated from startDay to endDay (inclusive), where "days" are "number of days ago". E.g., for the last 30 days, begin day would be 30 (days ago), end day would be 0 (days ago) (up until now).

func (*StatsStore) RunsStartedPerWeekLastXWeeks

func (s *StatsStore) RunsStartedPerWeekLastXWeeks(x int, filters *StatsFilters) ([]int, [][]int64)

RunsStartedPerWeekLastXWeeks returns the number of runs started each week for the last X weeks. Returns data in order of oldest week to most recent week.

func (*StatsStore) TotalActiveParticipants

func (s *StatsStore) TotalActiveParticipants(filters *StatsFilters) int

func (*StatsStore) TotalInProgressPlaybookRuns

func (s *StatsStore) TotalInProgressPlaybookRuns(filters *StatsFilters) int

func (*StatsStore) TotalPlaybookRuns added in v1.28.0

func (s *StatsStore) TotalPlaybookRuns() (int, error)

TotalPlaybookRuns returns the number of playbook runs in the server

func (*StatsStore) TotalPlaybooks added in v1.28.0

func (s *StatsStore) TotalPlaybooks() (int, error)

TotalPlaybooks returns the number of playbooks in the server

type StoreAPI

type StoreAPI interface {
	GetMasterDB() (*sql.DB, error)
	DriverName() string
}

StoreAPI is the interface exposing the underlying database, provided by pluginapi It is implemented by mattermost-plugin-api/Client.Store, or by the mock StoreAPI.

type TableInfo added in v1.32.0

type TableInfo struct {
	TableName              string
	ColumnName             string
	DataType               string
	IsNullable             string
	ColumnKey              string
	ColumnDefault          *string
	Extra                  string
	CharacterMaximumLength *string
}

Directories

Path Synopsis
Package mock_sqlstore is a generated GoMock package.
Package mock_sqlstore is a generated GoMock package.
Package mock_sqlstore is a generated GoMock package.
Package mock_sqlstore is a generated GoMock package.

Jump to

Keyboard shortcuts

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