Skip to content

Commit

Permalink
feat(framework): fetch project list by keyword (#7689) (#7690)
Browse files Browse the repository at this point in the history
Co-authored-by: Lynwee <[email protected]>
  • Loading branch information
github-actions[bot] and d4x1 authored Jul 2, 2024
1 parent b4cbc17 commit ff0b290
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 11 additions & 0 deletions backend/server/services/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ import (
// ProjectQuery used to query projects as the api project input
type ProjectQuery struct {
Pagination
Keyword *string `json:"keyword" form:"keyword"`
}

func (query *ProjectQuery) GetKeyword() string {
if query != nil && query.Keyword != nil {
return *query.Keyword
}
return ""
}

// GetProjects returns a paginated list of Projects based on `query`
Expand All @@ -43,6 +51,9 @@ func GetProjects(query *ProjectQuery) ([]*models.ApiOutputProject, int64, errors
clauses := []dal.Clause{
dal.From(&models.Project{}),
}
if query.Keyword != nil {
clauses = append(clauses, dal.Where("name LIKE ?", "%"+query.GetKeyword()+"%"))
}

count, err := db.Count(clauses...)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion backend/server/services/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/apache/incubator-devlake/core/models"
)

// GetProjects returns a paginated list of Projects based on `query`
func GetStore(storeKey string) (*models.Store, errors.Error) {
clauses := []dal.Clause{
dal.From(&models.Store{}),
Expand Down

0 comments on commit ff0b290

Please sign in to comment.