repositories

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildJsonCondition

func BuildJsonCondition(
	dialector string,
	jsonColumnName string,
	jsonPathValueMap map[string]string,
) (sql string, args []any)

BuildJsonCondition creates sql and values for where condition to select items having the specified map of json paths and values in the given json column. Json path is expressed as "key" or "outerkey.nestedKey".

Types

type AppRepository

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

AppRepository repository to work with `app` entity.

func NewAppRepository

func NewAppRepository(db *gorm.DB) *AppRepository

NewAppRepository creates repository to work with `app` entity.

func (AppRepository) Create

func (r AppRepository) Create(ctx context.Context, app *models.App) error

Create creates new app object.

func (AppRepository) Delete

func (r AppRepository) Delete(ctx context.Context, app *models.App) error

Delete deletes existing database.App object.

func (AppRepository) GetActiveAppsByNamespace

func (r AppRepository) GetActiveAppsByNamespace(ctx context.Context, namespaceID uint) ([]models.App, error)

GetActiveAppsByNamespace returns the list of active apps by provided Namespace ID.

func (AppRepository) GetByNamespaceIDAndAppID

func (r AppRepository) GetByNamespaceIDAndAppID(
	ctx context.Context, namespaceID uint, appID string,
) (*models.App, error)

GetByNamespaceIDAndAppID returns database.App by Namespace and App ID.

func (AppRepository) Update

func (r AppRepository) Update(ctx context.Context, app *models.App) error

Update updates existing database.App object.

type AppRepositoryProvider

type AppRepositoryProvider interface {
	// Update updates existing database.App object.
	Update(cxt context.Context, app *models.App) error
	// Create creates new database.App object.
	Create(ctx context.Context, app *models.App) error
	// Delete deletes existing database.App object.
	Delete(ctx context.Context, app *models.App) error
	// GetByNamespaceIDAndAppID returns database.App by Namespace and App ID.
	GetByNamespaceIDAndAppID(ctx context.Context, namespaceID uint, appID string) (*models.App, error)
	// GetActiveAppsByNamespace returns the list of active database.App by provided Namespace ID.
	GetActiveAppsByNamespace(ctx context.Context, namespaceID uint) ([]models.App, error)
}

AppRepositoryProvider provides an interface to work with `app` entity.

type DashboardRepository

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

DashboardRepository repository to work with `dashboard` entity.

func NewDashboardRepository

func NewDashboardRepository(db *gorm.DB) *DashboardRepository

NewDashboardRepository creates repository to work with `dashboard` entity.

func (DashboardRepository) Create

func (d DashboardRepository) Create(ctx context.Context, dashboard *models.Dashboard) error

Create creates new models.Dashboard object.

func (DashboardRepository) Delete

func (d DashboardRepository) Delete(ctx context.Context, dashboard *models.Dashboard) error

Delete deletes a models.Dashboard object.

func (DashboardRepository) GetByNamespaceIDAndDashboardID

func (d DashboardRepository) GetByNamespaceIDAndDashboardID(ctx context.Context,
	namespaceID uint, dashboardID string,
) (*models.Dashboard, error)

GetByNamespaceIDAndDashboardID returns models.Dashboard by Namespace and Dashboard ID.

func (DashboardRepository) GetDashboardsByNamespace

func (d DashboardRepository) GetDashboardsByNamespace(ctx context.Context,
	namespaceID uint,
) ([]models.Dashboard, error)

GetDashboardsByNamespace returns the list of active models.Dashboard by provided Namespace ID.

func (DashboardRepository) Update

func (d DashboardRepository) Update(ctx context.Context, dashboard *models.Dashboard) error

Update updates existing models.Dashboard object.

type DashboardRepositoryProvider

type DashboardRepositoryProvider interface {
	// Update updates existing models.Dashboard object.
	Update(cxt context.Context, dashboard *models.Dashboard) error
	// Create creates new models.Dashboard object.
	Create(ctx context.Context, dashboard *models.Dashboard) error
	// Delete deletes existing models.Dashboard object.
	Delete(ctx context.Context, dashboard *models.Dashboard) error
	// GetDashboardsByNamespace returns the list of active models.Dashboard by provided Namespace ID.
	GetDashboardsByNamespace(ctx context.Context, namespaceID uint) ([]models.Dashboard, error)
	// GetByNamespaceIDAndDashboardID returns models.Dashboard by Dashboard ID.
	GetByNamespaceIDAndDashboardID(
		ctx context.Context, namespaceID uint, dashboardID string,
	) (*models.Dashboard, error)
}

DashboardRepositoryProvider provides an interface to work with `dashboard` entity.

type ExperimentRepository

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

ExperimentRepository repository to work with `experiment` entity.

func NewExperimentRepository

func NewExperimentRepository(db *gorm.DB) *ExperimentRepository

NewExperimentRepository creates repository to work with `experiment` entity.

func (ExperimentRepository) Delete

func (r ExperimentRepository) Delete(ctx context.Context, experiment *models.Experiment) error

Delete deletes existing experiment.

func (ExperimentRepository) GetCountOfActiveExperiments

func (r ExperimentRepository) GetCountOfActiveExperiments(ctx context.Context, namespaceID uint) (int64, error)

GetCountOfActiveExperiments returns count of active experiments.

func (ExperimentRepository) GetExperimentActivity

func (r ExperimentRepository) GetExperimentActivity(
	ctx context.Context, namespaceID uint, experimentID int32, tzOffset int,
) (*models.ExperimentActivity, error)

GetExperimentActivity returns experiment activity.

func (ExperimentRepository) GetExperimentByNamespaceIDAndExperimentID

func (r ExperimentRepository) GetExperimentByNamespaceIDAndExperimentID(
	ctx context.Context, namespaceID uint, experimentID int32,
) (*models.Experiment, error)

GetExperimentByNamespaceIDAndExperimentID returns experiment by Namespace ID and Experiment ID.

func (ExperimentRepository) GetExperimentRuns

func (r ExperimentRepository) GetExperimentRuns(
	ctx context.Context, req *request.GetExperimentRunsRequest,
) ([]models.Run, error)

GetExperimentRuns returns list of runs which belong to experiment.

func (ExperimentRepository) GetExperiments

func (r ExperimentRepository) GetExperiments(
	ctx context.Context, namespaceID uint,
) ([]models.ExperimentExtended, error)

GetExperiments returns list of experiments.

func (ExperimentRepository) GetExtendedExperimentByNamespaceIDAndExperimentID

func (r ExperimentRepository) GetExtendedExperimentByNamespaceIDAndExperimentID(
	ctx context.Context, namespaceID uint, experimentID int32,
) (*models.ExperimentExtended, error)

GetExtendedExperimentByNamespaceIDAndExperimentID returns experiment by Namespace ID and Experiment ID. TODO:dsuhinin this moment needs to be discussed.

func (ExperimentRepository) Update

func (r ExperimentRepository) Update(ctx context.Context, experiment *models.Experiment) error

Update updates existing experiment.

type ExperimentRepositoryProvider

type ExperimentRepositoryProvider interface {
	// Update updates existing experiment.
	Update(ctx context.Context, experiment *models.Experiment) error
	// Delete deletes existing experiment.
	Delete(ctx context.Context, experiment *models.Experiment) error
	// GetExperiments returns list of experiments.
	GetExperiments(ctx context.Context, namespaceID uint) ([]models.ExperimentExtended, error)
	// GetExperimentRuns returns list of runs which belong to experiment.
	GetExperimentRuns(ctx context.Context, req *request.GetExperimentRunsRequest) ([]models.Run, error)
	// GetExperimentActivity returns experiment activity.
	GetExperimentActivity(
		ctx context.Context, namespaceID uint, experimentID int32, tzOffset int,
	) (*models.ExperimentActivity, error)
	// GetExperimentByNamespaceIDAndExperimentID returns experiment by Namespace ID and Experiment ID.
	GetExperimentByNamespaceIDAndExperimentID(
		ctx context.Context, namespaceID uint, experimentID int32,
	) (*models.Experiment, error)
	// GetCountOfActiveExperiments returns count of active experiments.
	GetCountOfActiveExperiments(ctx context.Context, namespaceID uint) (int64, error)
	// GetExtendedExperimentByNamespaceIDAndExperimentID returns extended experiment by Namespace ID and Experiment ID.
	GetExtendedExperimentByNamespaceIDAndExperimentID(
		ctx context.Context, namespaceID uint, experimentID int32,
	) (*models.ExperimentExtended, error)
}

ExperimentRepositoryProvider provides an interface to work with `experiment` entity.

type MetricRepository

type MetricRepository struct {
	repositories.BaseRepositoryProvider
}

MetricRepository repository to work with models.Metric entity.

func NewMetricRepository

func NewMetricRepository(db *gorm.DB) *MetricRepository

NewMetricRepository creates repository to work with models.Metric entity.

func (MetricRepository) GetContextListByContextObjects

func (r MetricRepository) GetContextListByContextObjects(
	ctx context.Context, contextsMap map[string]types.JSONB,
) ([]models.Context, error)

GetContextListByContextObjects returns list of context by provided map of contexts.

func (MetricRepository) GetMetricKeysAndContextsByExperiments

func (r MetricRepository) GetMetricKeysAndContextsByExperiments(
	ctx context.Context, namespaceID uint, experiments []int,
) ([]models.LatestMetric, error)

GetMetricKeysAndContextsByExperiments returns metric keys and contexts by provided experiments.

func (MetricRepository) SearchMetrics

func (r MetricRepository) SearchMetrics(
	ctx context.Context, namespaceID uint, timeZoneOffset int, req request.SearchMetricsRequest,
) (*sql.Rows, int64, SearchResultMap, error)

SearchMetrics returns a metrics cursor according to the SearchMetricsRequest.

type MetricRepositoryProvider

type MetricRepositoryProvider interface {
	repositories.BaseRepositoryProvider
	// GetMetricKeysAndContextsByExperiments returns metric keys and contexts by provided experiments.
	GetMetricKeysAndContextsByExperiments(
		ctx context.Context, namespaceID uint, experiments []int,
	) ([]models.LatestMetric, error)
	// SearchMetrics returns a sql.Rows cursor for streaming the metrics matching the request.
	SearchMetrics(
		ctx context.Context, namespaceID uint, timeZoneOffset int, req request.SearchMetricsRequest,
	) (*sql.Rows, int64, SearchResultMap, error)
	// GetContextListByContextObjects returns list of context by provided map of contexts.
	GetContextListByContextObjects(
		ctx context.Context, contextsMap map[string]types.JSONB,
	) ([]models.Context, error)
}

MetricRepositoryProvider provides an interface to work with models.Metric entity.

type ParamRepository

type ParamRepository struct {
	repositories.BaseRepositoryProvider
}

ParamRepository repository to work with models.Param entity.

func NewParamRepository

func NewParamRepository(db *gorm.DB) *ParamRepository

NewParamRepository creates repository to work with models.Param entity.

func (ParamRepository) GetParamKeysByParameters

func (r ParamRepository) GetParamKeysByParameters(
	ctx context.Context, namespaceID uint, experiments []int,
) ([]string, error)

GetParamKeysByParameters returns list of param keys by requested parameters.

type ParamRepositoryProvider

type ParamRepositoryProvider interface {
	// GetParamKeysByParameters returns list of param keys by requested parameters.
	GetParamKeysByParameters(ctx context.Context, namespaceID uint, experiments []int) ([]string, error)
}

ParamRepositoryProvider provides an interface to work with models.Param entity.

type RunRepository

type RunRepository struct {
	repositories.BaseRepositoryProvider
}

RunRepository repository to work with models.Run entity.

func NewRunRepository

func NewRunRepository(db *gorm.DB) *RunRepository

NewRunRepository creates repository to work with models.Run entity.

func (RunRepository) ArchiveBatch

func (r RunRepository) ArchiveBatch(ctx context.Context, namespaceID uint, ids []string) error

ArchiveBatch marks existing models.Run entities as archived.

func (RunRepository) Delete

func (r RunRepository) Delete(ctx context.Context, namespaceID uint, run *models.Run) error

Delete removes the existing models.Run from the db.

func (RunRepository) DeleteBatch

func (r RunRepository) DeleteBatch(ctx context.Context, namespaceID uint, ids []string) error

DeleteBatch removes existing models.Run from the db.

func (RunRepository) GetAlignedMetrics

func (r RunRepository) GetAlignedMetrics(
	ctx context.Context, namespaceID uint, values []any, alignBy string,
) (*sql.Rows, func(rows *sql.Rows) (*models.AlignedMetric, error), error)

GetAlignedMetrics returns aligned metrics.

func (RunRepository) GetByNamespaceID

func (r RunRepository) GetByNamespaceID(ctx context.Context, namespaceID uint) ([]models.Run, error)

GetByNamespaceID returns list of models.Run by requested namespace ID.

func (RunRepository) GetByNamespaceIDAndStatus

func (r RunRepository) GetByNamespaceIDAndStatus(
	ctx context.Context, namespaceID uint, status models.Status,
) ([]models.Run, error)

GetByNamespaceIDAndStatus returns []models.Run by Namespace ID and Lifecycle Stage.

func (RunRepository) GetRunByNamespaceIDAndRunID

func (r RunRepository) GetRunByNamespaceIDAndRunID(
	ctx context.Context, namespaceID uint, runID string,
) (*models.Run, error)

GetRunByNamespaceIDAndRunID returns experiment by Namespace ID and Run ID.

func (RunRepository) GetRunInfo

func (r RunRepository) GetRunInfo(
	ctx context.Context, namespaceID uint, req *request.GetRunInfoRequest,
) (*models.Run, error)

GetRunInfo returns run info.

func (RunRepository) GetRunMetrics

func (r RunRepository) GetRunMetrics(
	ctx context.Context, runID string, metricKeysMap models.MetricKeysMap,
) ([]models.Metric, error)

GetRunMetrics returns Run metrics.

func (RunRepository) RestoreBatch

func (r RunRepository) RestoreBatch(ctx context.Context, namespaceID uint, ids []string) error

RestoreBatch marks existing models.Run entities as active.

func (RunRepository) SearchRuns

func (r RunRepository) SearchRuns(
	ctx context.Context, namespaceID uint, timeZoneOffset int, req request.SearchRunsRequest,
) ([]models.Run, int64, error)

SearchRuns returns the list of runs by provided search request.

func (RunRepository) Update

func (r RunRepository) Update(ctx context.Context, run *models.Run) error

Update updates existing models.Run entity.

func (RunRepository) UpdateWithTransaction

func (r RunRepository) UpdateWithTransaction(ctx context.Context, tx *gorm.DB, run *models.Run) error

UpdateWithTransaction updates existing models.Run entity in scope of transaction.

type RunRepositoryProvider

type RunRepositoryProvider interface {
	repositories.BaseRepositoryProvider
	// GetRunInfo returns run info.
	GetRunInfo(ctx context.Context, namespaceID uint, req *request.GetRunInfoRequest) (*models.Run, error)
	// GetRunMetrics returns Run metrics.
	GetRunMetrics(ctx context.Context, runID string, metricKeysMap models.MetricKeysMap) ([]models.Metric, error)
	// GetAlignedMetrics returns aligned metrics.
	GetAlignedMetrics(
		ctx context.Context, namespaceID uint, values []any, alignBy string,
	) (*sql.Rows, func(*sql.Rows) (*models.AlignedMetric, error), error)
	// GetRunByNamespaceIDAndRunID returns experiment by Namespace ID and Run ID.
	GetRunByNamespaceIDAndRunID(ctx context.Context, namespaceID uint, runID string) (*models.Run, error)
	// GetByNamespaceID returns list of models.Run by requested namespace ID.
	GetByNamespaceID(ctx context.Context, namespaceID uint) ([]models.Run, error)
	// GetByNamespaceIDAndStatus returns []models.Run by Namespace ID and status.
	GetByNamespaceIDAndStatus(ctx context.Context, namespaceID uint, status models.Status) ([]models.Run, error)
	// Update updates existing models.Experiment entity.
	Update(ctx context.Context, run *models.Run) error
	// ArchiveBatch marks existing models.Run entities as archived.
	ArchiveBatch(ctx context.Context, namespaceID uint, ids []string) error
	// DeleteBatch removes the existing models.Run from the db.
	DeleteBatch(ctx context.Context, namespaceID uint, ids []string) error
	// RestoreBatch marks existing models.Run entities as active.
	RestoreBatch(ctx context.Context, namespaceID uint, ids []string) error
	// SearchRuns returns the list of runs by provided search request.
	SearchRuns(
		ctx context.Context, namespaceID uint, tzOffset int, req request.SearchRunsRequest,
	) ([]models.Run, int64, error)
}

RunRepositoryProvider provides an interface to work with models.Run entity.

type SearchResult

type SearchResult struct {
	RowNum int64
	Info   fiber.Map
}

SearchResult is a helper for reporting result progress.

type SearchResultMap

type SearchResultMap = map[string]SearchResult

SearchResultMap is a helper for reporting result progress.

type TagRepository

type TagRepository struct {
	repositories.BaseRepositoryProvider
}

TagRepository repository to work with models.Tag entity.

func NewTagRepository

func NewTagRepository(db *gorm.DB) *TagRepository

NewTagRepository creates repository to work with models.Tag entity.

func (TagRepository) CreateExperimentTag

func (r TagRepository) CreateExperimentTag(ctx context.Context, experimentTag *models.ExperimentTag) error

CreateExperimentTag creates new models.ExperimentTag entity connected to models.Experiment.

func (TagRepository) GetTagKeysByParameters

func (r TagRepository) GetTagKeysByParameters(
	ctx context.Context, namespaceID uint, experiments []int,
) ([]string, error)

GetTagKeysByParameters returns list of tag keys by requested parameters.

func (TagRepository) GetTagsByNamespace

func (r TagRepository) GetTagsByNamespace(ctx context.Context, namespaceID uint) ([]models.Tag, error)

GetTagsByNamespace returns the list of tags. TODO fix stub implementation

type TagRepositoryProvider

type TagRepositoryProvider interface {
	repositories.BaseRepositoryProvider
	// GetTagsByNamespace returns the list of tags.
	GetTagsByNamespace(ctx context.Context, namespaceID uint) ([]models.Tag, error)
	// CreateExperimentTag creates new models.ExperimentTag entity connected to models.Experiment.
	CreateExperimentTag(ctx context.Context, experimentTag *models.ExperimentTag) error
	// GetTagKeysByParameters returns list of tag keys by requested parameters.
	GetTagKeysByParameters(ctx context.Context, namespaceID uint, experiments []int) ([]string, error)
}

TagRepositoryProvider provides an interface to work with models.Tag entity.

Jump to

Keyboard shortcuts

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