Skip to content

Commit dd1ad16

Browse files
committed
feat: add sort options in runs and projects list api
1 parent 2032359 commit dd1ad16

File tree

5 files changed

+3
-5
lines changed

5 files changed

+3
-5
lines changed

pkg/infra/persistence/project.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (r *projectRepository) List(ctx context.Context, filter *entity.ProjectFilt
117117

118118
sortArgs := sortOptions.Field
119119
if !sortOptions.Ascending {
120-
sortArgs = sortArgs + " DESC"
120+
sortArgs += " DESC"
121121
}
122122

123123
searchResult := r.db.WithContext(ctx).

pkg/infra/persistence/project_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func TestProjectRepository(t *testing.T) {
162162
sqlmock.NewRows([]string{"count"}).
163163
AddRow(2))
164164

165-
sqlMock.ExpectQuery("SELECT .* FROM `project` .* IS NULL LIMIT").
165+
sqlMock.ExpectQuery("SELECT .* FROM `project` .* IS NULL .* LIMIT").
166166
WillReturnRows(
167167
sqlmock.NewRows([]string{"id", "name", "path", "Organization__id", "Organization__name", "Organization__owners", "Source__id", "Source__remote", "Source__source_provider"}).
168168
AddRow(expectedID, expectedName, expectedPath, 1, "mockedOrg", expectedOrgOwners, 1, "https://github.com/test/repo", constant.SourceProviderTypeGithub).

pkg/infra/persistence/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (r *runRepository) List(ctx context.Context, filter *entity.RunFilter, sort
103103

104104
sortArgs := sortOptions.Field
105105
if !sortOptions.Ascending {
106-
sortArgs = sortArgs + " DESC"
106+
sortArgs += " DESC"
107107
}
108108

109109
searchResult := r.db.WithContext(ctx).

pkg/server/handler/stack/handler.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//nolint:dupl
21
package stack
32

43
import (

pkg/server/handler/stack/run.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//nolint:dupl
21
package stack
32

43
import (

0 commit comments

Comments
 (0)