feat(backend): sorting on run metrics - step 1 (#4203)

* enable pagination when expanding experiment in both the home page and the archive page

* Revert "enable pagination when expanding experiment in both the home page and the archive page"

This reverts commit 5b672739dd.

* metrics as the outermost

* columns swap
This commit is contained in:
jingzhang36 2020-07-14 08:33:21 +08:00 committed by GitHub
parent 1a60c02660
commit a96e8fe94e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 8 deletions

View File

@ -214,19 +214,18 @@ func (s *RunStore) GetRun(runId string) (*model.RunDetail, error) {
}
func (s *RunStore) addMetricsAndResourceReferences(filteredSelectBuilder sq.SelectBuilder) sq.SelectBuilder {
metricConcatQuery := s.db.Concat([]string{`"["`, s.db.GroupConcat("m.Payload", ","), `"]"`}, "")
resourceRefConcatQuery := s.db.Concat([]string{`"["`, s.db.GroupConcat("rr.Payload", ","), `"]"`}, "")
subQ := sq.
Select("rd.*", metricConcatQuery+" AS metrics").
Select("rd.*", resourceRefConcatQuery+" AS refs").
FromSelect(filteredSelectBuilder, "rd").
LeftJoin("run_metrics AS m ON rd.UUID=m.RunUUID").
LeftJoin("resource_references AS rr ON rr.ResourceType='Run' AND rd.UUID=rr.ResourceUUID").
GroupBy("rd.UUID")
resourceRefConcatQuery := s.db.Concat([]string{`"["`, s.db.GroupConcat("r.Payload", ","), `"]"`}, "")
metricConcatQuery := s.db.Concat([]string{`"["`, s.db.GroupConcat("rm.Payload", ","), `"]"`}, "")
return sq.
Select("subq.*", resourceRefConcatQuery+" AS refs").
Select("subq.*", metricConcatQuery+" AS metrics").
FromSelect(subQ, "subq").
// Append all the resource references for the run as a json column
LeftJoin("resource_references AS r ON r.ResourceType='Run' AND subq.UUID=r.ResourceUUID").
LeftJoin("run_metrics AS rm ON subq.UUID=rm.RunUUID").
GroupBy("subq.UUID")
}
@ -258,8 +257,8 @@ func (s *RunStore) scanRowsToRunDetails(rows *sql.Rows) ([]*model.RunDetail, err
&parameters,
&pipelineRuntimeManifest,
&workflowRuntimeManifest,
&metricsInString,
&resourceReferencesInString,
&metricsInString,
)
if err != nil {
glog.Errorf("Failed to scan row: %v", err)