summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2018-11-29 09:46:30 +0800
committerGitHub <noreply@github.com>2018-11-29 09:46:30 +0800
commit2dc805c0c6e85099f3f346ba78f3a52abf032ce4 (patch)
tree2adeae8beaa207c80908914d3f6e48d82e2ae21d /models
parentd5d847e5c4f0cf1470fc51f96d57917e4d9f5d83 (diff)
downloadgitea-2dc805c0c6e85099f3f346ba78f3a52abf032ce4.tar.gz
gitea-2dc805c0c6e85099f3f346ba78f3a52abf032ce4.zip
Milestone issues and pull requests (#5293)
* add milestone issues and pulls page instead of redirecting issues page * add milestone when creating issue from milestone page * refactor to merge similiar codes as a new function issues * remove milestone info on milestone issues list * fix missing params
Diffstat (limited to 'models')
-rw-r--r--models/issue.go12
-rw-r--r--models/issue_milestone.go12
2 files changed, 21 insertions, 3 deletions
diff --git a/models/issue.go b/models/issue.go
index 26196274fe..d4222b04a0 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -1401,7 +1401,7 @@ type IssueStatsOptions struct {
AssigneeID int64
MentionedID int64
PosterID int64
- IsPull bool
+ IsPull util.OptionalBool
IssueIDs []int64
}
@@ -1411,8 +1411,7 @@ func GetIssueStats(opts *IssueStatsOptions) (*IssueStats, error) {
countSession := func(opts *IssueStatsOptions) *xorm.Session {
sess := x.
- Where("issue.repo_id = ?", opts.RepoID).
- And("issue.is_pull = ?", opts.IsPull)
+ Where("issue.repo_id = ?", opts.RepoID)
if len(opts.IssueIDs) > 0 {
sess.In("issue.id", opts.IssueIDs)
@@ -1447,6 +1446,13 @@ func GetIssueStats(opts *IssueStatsOptions) (*IssueStats, error) {
And("issue_user.is_mentioned = ?", true)
}
+ switch opts.IsPull {
+ case util.OptionalBoolTrue:
+ sess.And("issue.is_pull=?", true)
+ case util.OptionalBoolFalse:
+ sess.And("issue.is_pull=?", false)
+ }
+
return sess
}
diff --git a/models/issue_milestone.go b/models/issue_milestone.go
index 2e512d7ba4..6cb2b6b574 100644
--- a/models/issue_milestone.go
+++ b/models/issue_milestone.go
@@ -122,6 +122,18 @@ func GetMilestoneByRepoID(repoID, id int64) (*Milestone, error) {
return getMilestoneByRepoID(x, repoID, id)
}
+// GetMilestoneByID returns the milestone via id .
+func GetMilestoneByID(id int64) (*Milestone, error) {
+ var m Milestone
+ has, err := x.ID(id).Get(&m)
+ if err != nil {
+ return nil, err
+ } else if !has {
+ return nil, ErrMilestoneNotExist{id, 0}
+ }
+ return &m, nil
+}
+
// MilestoneList is a list of milestones offering additional functionality
type MilestoneList []*Milestone