Skip to content

Commit

Permalink
feat(server): add sort, search and starred project functionality (#1040)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyshx authored Jul 1, 2024
1 parent 0fe2618 commit c27aad4
Show file tree
Hide file tree
Showing 19 changed files with 346 additions and 31 deletions.
10 changes: 9 additions & 1 deletion server/gql/project.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ type Project implements Node {
coreSupport: Boolean!
enableGa: Boolean!
trackingId: String!
starred: Boolean!
}

enum ProjectSortType {
CREATEDAT
UPDATEDAT
NAME
}

type ProjectAliasAvailability {
Expand Down Expand Up @@ -72,6 +79,7 @@ input UpdateProjectInput {
enableGa: Boolean
trackingId: String
sceneId: ID
starred: Boolean
}

input PublishProjectInput {
Expand Down Expand Up @@ -109,7 +117,7 @@ type ProjectEdge {
}

extend type Query{
projects(teamId: ID!, includeArchived: Boolean, first: Int, last: Int, after: Cursor, before: Cursor): ProjectConnection!
projects(teamId: ID!, includeArchived: Boolean, first: Int, last: Int, after: Cursor, before: Cursor, keyword: String, sort: ProjectSortType): ProjectConnection!
checkProjectAlias(alias: String!): ProjectAliasAvailability!
}

Expand Down
126 changes: 120 additions & 6 deletions server/internal/adapter/gql/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions server/internal/adapter/gql/gqlmodel/convert_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,21 @@ func ToProject(p *project.Project) *Project {
CoreSupport: p.CoreSupport(),
EnableGa: p.EnableGA(),
TrackingID: p.TrackingID(),
Starred: p.Starred(),
}
}
func ProjectSortTypeFrom(pst *ProjectSortType) *project.SortType {
if pst == nil {
return nil
}

switch *pst {
case ProjectSortTypeCreatedat:
return &project.SortTypeID
case ProjectSortTypeUpdatedat:
return &project.SortTypeUpdatedAt
case ProjectSortTypeName:
return &project.SortTypeName
}
return &project.SortTypeUpdatedAt
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func TestToProject(t *testing.T) {
CoreSupport: false,
EnableGa: false,
TrackingID: "",
Starred: false,
},
},
}
Expand Down
45 changes: 45 additions & 0 deletions server/internal/adapter/gql/gqlmodel/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c27aad4

Please sign in to comment.