Skip to content

Commit

Permalink
fix(backend): improve forward / backward compatibility on experiment …
Browse files Browse the repository at this point in the history
…table (#4349)
  • Loading branch information
frozeNinK authored Aug 12, 2020
1 parent f35462f commit 5141201
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions backend/src/apiserver/storage/experiment_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ type ExperimentStore struct {
defaultExperimentStore *DefaultExperimentStore
}

var (
experimentColumns = []string{
"UUID",
"Name",
"Description",
"CreatedAtInSec",
"Namespace",
"StorageState",
}
)

// Runs two SQL queries in a transaction to return a list of matching experiments, as well as their
// total_size. The total_size does not reflect the page size.
func (s *ExperimentStore) ListExperiments(filterContext *common.FilterContext, opts *list.Options) ([]*model.Experiment, int, string, error) {
Expand All @@ -39,7 +50,7 @@ func (s *ExperimentStore) ListExperiments(filterContext *common.FilterContext, o
}

// SQL for getting the filtered and paginated rows
sqlBuilder := sq.Select("*").From("experiments")
sqlBuilder := sq.Select(experimentColumns...).From("experiments")
if filterContext.ReferenceKey != nil && filterContext.ReferenceKey.Type == common.Namespace {
sqlBuilder = sqlBuilder.Where(sq.Eq{"Namespace": filterContext.ReferenceKey.ID})
}
Expand Down Expand Up @@ -108,7 +119,7 @@ func (s *ExperimentStore) ListExperiments(filterContext *common.FilterContext, o

func (s *ExperimentStore) GetExperiment(uuid string) (*model.Experiment, error) {
sql, args, err := sq.
Select("*").
Select(experimentColumns...).
From("experiments").
Where(sq.Eq{"uuid": uuid}).
Limit(1).
Expand Down

0 comments on commit 5141201

Please sign in to comment.