Skip to content

Commit

Permalink
Addressing comments in PR 4134 (#4144)
Browse files Browse the repository at this point in the history
Refactoring based on PR comments
  • Loading branch information
samanbarghi committed Apr 5, 2023
1 parent 6f1f022 commit 0d6e92f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
Expand Up @@ -91,10 +91,6 @@ type (
// For ES>=7.10.0 and "default" flavor.
PointInTimeID string
}

searchParameterBuilder struct {
store *visibilityStore
}
)

var _ store.VisibilityStore = (*visibilityStore)(nil)
Expand Down Expand Up @@ -757,10 +753,6 @@ func (s *visibilityStore) getListFieldSorter(fieldSorts []*elastic.FieldSort) ([
if len(fieldSorts) == 0 {
return defaultSorter, nil
}
return s.getFieldSorter(fieldSorts), nil
}

func (s *visibilityStore) getFieldSorter(fieldSorts []*elastic.FieldSort) []elastic.Sorter {
s.metricsHandler.Counter(metrics.ElasticsearchCustomOrderByClauseCount.GetMetricName()).Record(1)
res := make([]elastic.Sorter, len(fieldSorts)+1)
for i, fs := range fieldSorts {
Expand All @@ -769,7 +761,7 @@ func (s *visibilityStore) getFieldSorter(fieldSorts []*elastic.FieldSort) []elas
// RunID is explicit tiebreaker.
res[len(res)-1] = elastic.NewFieldSort(searchattribute.RunID).Desc()

return res
return res, nil
}

func (s *visibilityStore) getListWorkflowExecutionsResponse(
Expand Down
Expand Up @@ -448,18 +448,6 @@ func (s *ESVisibilitySuite) TestGetScanFieldSorter() {
s.Error(err)
s.Nil(sorter)
}
func (s *ESVisibilitySuite) TestGetFieldSorter() {

// test passing non-empty fieldSorts and not sortByDoc
testFieldSorts := [2]*elastic.FieldSort{elastic.NewFieldSort("_test"), elastic.NewFieldSort("_second_tes")}
s.mockMetricsHandler.EXPECT().Counter(metrics.ElasticsearchCustomOrderByClauseCount.GetMetricName()).Return(metrics.NoopCounterMetricFunc)
sorter := s.visibilityStore.getFieldSorter(testFieldSorts[:])
expectedSorter := make([]elastic.Sorter, len(testFieldSorts)+1)
expectedSorter[0] = testFieldSorts[0]
expectedSorter[1] = testFieldSorts[1]
expectedSorter[2] = elastic.NewFieldSort(searchattribute.RunID).Desc()
s.Equal(expectedSorter, sorter)
}

func (s *ESVisibilitySuite) TestBuildSearchParametersV2() {
request := &manager.ListWorkflowExecutionsRequestV2{
Expand Down

0 comments on commit 0d6e92f

Please sign in to comment.