Merge remote-tracking branch 'upstream/develop' into feat/opamp-logparing

This commit is contained in:
nityanandagohain 2023-03-15 20:36:01 +05:30
commit 1c867d3b4c
2 changed files with 13 additions and 8 deletions

View File

@ -31,11 +31,11 @@ func (r *Repo) initDB(engine string) error {
} }
} }
func (r *Repo) GetConfigHistory(ctx context.Context, typ ElementTypeDef) ([]ConfigVersion, error) { func (r *Repo) GetConfigHistory(ctx context.Context, typ ElementTypeDef, limit int) ([]ConfigVersion, error) {
var c []ConfigVersion var c []ConfigVersion
err := r.db.SelectContext(ctx, &c, `SELECT err := r.db.SelectContext(ctx, &c, fmt.Sprintf(`SELECT
id,
version, version,
id,
element_type, element_type,
COALESCE(created_by, -1) as created_by, COALESCE(created_by, -1) as created_by,
created_at, created_at,
@ -45,9 +45,14 @@ func (r *Repo) GetConfigHistory(ctx context.Context, typ ElementTypeDef) ([]Conf
is_valid, is_valid,
disabled, disabled,
deploy_status, deploy_status,
deploy_result deploy_result,
last_hash,
last_config
FROM agent_config_versions AS v FROM agent_config_versions AS v
WHERE element_type = $1`, typ) WHERE element_type = $1
ORDER BY created_at desc, version desc
limit %v`, limit),
typ)
return c, err return c, err
} }

View File

@ -51,8 +51,8 @@ func GetConfigVersion(ctx context.Context, elementType ElementTypeDef, version i
return m.GetConfigVersion(ctx, elementType, version) return m.GetConfigVersion(ctx, elementType, version)
} }
func GetConfigHistory(ctx context.Context, typ ElementTypeDef) ([]ConfigVersion, error) { func GetConfigHistory(ctx context.Context, typ ElementTypeDef, limit int) ([]ConfigVersion, error) {
return m.GetConfigHistory(ctx, typ) return m.GetConfigHistory(ctx, typ, limit)
} }
// StartNewVersion launches a new config version for given set of elements // StartNewVersion launches a new config version for given set of elements