Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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