diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-27 15:24:11 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-27 15:24:11 -0400 |
commit | f76eb8a6662dd705f4c59fd59e583a315a1900d2 (patch) | |
tree | 24ec9b457cf5be1b018a72e65e68ee1bc82f5ca5 /models/issue.go | |
parent | 6b43067e1be051e8cd353d332d61613e18ad11f4 (diff) | |
download | gitea-f76eb8a6662dd705f4c59fd59e583a315a1900d2.tar.gz gitea-f76eb8a6662dd705f4c59fd59e583a315a1900d2.zip |
IP: RC Code Review
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/models/issue.go b/models/issue.go index 6b657b7b90..b05667c3a8 100644 --- a/models/issue.go +++ b/models/issue.go @@ -37,12 +37,7 @@ type Issue struct { } // CreateIssue creates new issue for repository. -func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int, name, labels, content string, isPull bool) (*Issue, error) { - count, err := GetIssueCount(repoId) - if err != nil { - return nil, err - } - +func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int, name, labels, content string, isPull bool) (issue *Issue, err error) { // TODO: find out mentions mentions := "" @@ -50,8 +45,8 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int, defer sess.Close() sess.Begin() - issue := &Issue{ - Index: count + 1, + issue = &Issue{ + Index: int64(issueCount) + 1, Name: name, RepoId: repoId, PosterId: userId, @@ -81,11 +76,6 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int, return issue, nil } -// GetIssueCount returns count of issues in the repository. -func GetIssueCount(repoId int64) (int64, error) { - return orm.Count(&Issue{RepoId: repoId}) -} - // GetIssueById returns issue object by given id. func GetIssueByIndex(repoId, index int64) (*Issue, error) { issue := &Issue{RepoId: repoId, Index: index} @@ -148,16 +138,10 @@ func GetIssues(userId, repoId, posterId, milestoneId int64, page int, isClosed, // UpdateIssue updates information of issue. func UpdateIssue(issue *Issue) error { - _, err := orm.Update(issue, &Issue{RepoId: issue.RepoId, Index: issue.Index}) + _, err := orm.Id(issue.Id).AllCols().Update(issue) return err } -func CloseIssue() { -} - -func ReopenIssue() { -} - // Label represents a list of labels of repository for issues. type Label struct { Id int64 @@ -197,8 +181,7 @@ func CreateComment(userId, issueId, commitId, line int64, content string) error sess.Begin() if _, err := orm.Insert(&Comment{PosterId: userId, IssueId: issueId, - CommitId: commitId, Line: line, Content: content, - }); err != nil { + CommitId: commitId, Line: line, Content: content}); err != nil { sess.Rollback() return err } |