You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ly...@apache.org on 2024/07/02 03:11:58 UTC

(incubator-devlake) branch dev0702 created (now 906d34a97)

This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a change to branch dev0702
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


      at 906d34a97 feat(framework): fetch project list by keyword

This branch includes the following new commits:

     new 906d34a97 feat(framework): fetch project list by keyword

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(incubator-devlake) 01/01: feat(framework): fetch project list by keyword

Posted by ly...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a commit to branch dev0702
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 906d34a97d5b21b29ef8e9130660890a0d0155cd
Author: d4x1 <15...@qq.com>
AuthorDate: Tue Jul 2 11:11:44 2024 +0800

    feat(framework): fetch project list by keyword
---
 backend/server/services/project.go | 11 +++++++++++
 backend/server/services/store.go   |  1 -
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/backend/server/services/project.go b/backend/server/services/project.go
index e119979ab..8e87d1c81 100644
--- a/backend/server/services/project.go
+++ b/backend/server/services/project.go
@@ -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`
@@ -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 {
diff --git a/backend/server/services/store.go b/backend/server/services/store.go
index 1eb4b717c..5b4e250c2 100644
--- a/backend/server/services/store.go
+++ b/backend/server/services/store.go
@@ -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{}),