Skip to content

Commit

Permalink
Align sort inversion with pagination direction.
Browse files Browse the repository at this point in the history
Fixes #3966
  • Loading branch information
blkt committed Jul 23, 2024
1 parent 2b5bb5d commit 467530f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/history/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (_ *evaluationHistoryService) ListEvaluationHistory(
return nil, errors.New("internal error")
}

if cursor != nil && cursor.Direction == Next {
if cursor != nil && cursor.Direction == Prev {
slices.Reverse(rows)
}

Expand Down
8 changes: 4 additions & 4 deletions internal/history/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func TestListEvaluationHistory(t *testing.T) {

// cursor flips on direction
{
name: "prev does not flip",
name: "next does not flip",
dbSetup: dbf.NewDBMock(
withListEvaluationHistory(nil, nil,
makeHistoryRow(
Expand All @@ -230,7 +230,7 @@ func TestListEvaluationHistory(t *testing.T) {
),
),
cursor: &ListEvaluationCursor{
Direction: Prev,
Direction: Next,
},
checkf: func(t *testing.T, rows *ListEvaluationHistoryResult) {
t.Helper()
Expand All @@ -251,7 +251,7 @@ func TestListEvaluationHistory(t *testing.T) {
},
},
{
name: "next does flip",
name: "prev does flip",
dbSetup: dbf.NewDBMock(
withListEvaluationHistory(nil, nil,
makeHistoryRow(
Expand All @@ -271,7 +271,7 @@ func TestListEvaluationHistory(t *testing.T) {
),
),
cursor: &ListEvaluationCursor{
Direction: Next,
Direction: Prev,
},
checkf: func(t *testing.T, rows *ListEvaluationHistoryResult) {
t.Helper()
Expand Down

0 comments on commit 467530f

Please sign in to comment.