|
|
|
@@ -3,6 +3,7 @@ package models |
|
|
|
import ( |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/timeutil" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
type SearchRecord struct { |
|
|
|
@@ -27,18 +28,23 @@ func SaveSearchKeywordToDb(keyword string) error { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func SearchPrivateIssueOrPr(Page int, PageSize int, Keyword string, isPull bool, userId int64) ([]*Issue, int64, error) { |
|
|
|
sess := x.NewSession() |
|
|
|
defer sess.Close() |
|
|
|
|
|
|
|
func setQueryCondition(sess *xorm.Session, Keyword string, isPull bool, userId int64) { |
|
|
|
sess.And("issue.poster_id=?", userId) |
|
|
|
sess.And("issue.is_pull=?", isPull) |
|
|
|
sess.And("(issue.name like '%" + Keyword + "%' or issue.content like '%" + Keyword + "%')") |
|
|
|
sess.Join("INNER", "repository", "issue.repo_id = repository.id").And("repository.is_private = ?", true) |
|
|
|
} |
|
|
|
|
|
|
|
func SearchPrivateIssueOrPr(Page int, PageSize int, Keyword string, isPull bool, userId int64) ([]*Issue, int64, error) { |
|
|
|
sess := x.NewSession() |
|
|
|
defer sess.Close() |
|
|
|
setQueryCondition(sess, Keyword, isPull, userId) |
|
|
|
count, err := sess.Count(new(Issue)) |
|
|
|
if err != nil { |
|
|
|
return nil, 0, err |
|
|
|
} |
|
|
|
|
|
|
|
//setQueryCondition(sess, Keyword, isPull, userId) |
|
|
|
sess.Desc("issue.created_unix") |
|
|
|
sess.Limit(PageSize, (Page-1)*PageSize) |
|
|
|
issues := make([]*Issue, 0) |
|
|
|
|