Browse Source

issue_comment: fix pg syntax ambiguous (#4586)

Also handle error related to time parsing.
pull/4590/merge
Unknwon 8 years ago
parent
commit
8ed2330d6e
No known key found for this signature in database
GPG Key ID: 7A02C406FAC875A2
  1. 2
      gogs.go
  2. 4
      models/comment.go
  3. 14
      routes/api/v1/repo/issue_comment.go
  4. 2
      templates/.VERSION

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const APP_VER = "0.11.23.0625" const APP_VER = "0.11.24.0627"
func init() { func init() {
setting.AppVer = APP_VER setting.AppVer = APP_VER

4
models/comment.go

@ -437,9 +437,9 @@ func getCommentsByIssueIDSince(e Engine, issueID, since int64) ([]*Comment, erro
func getCommentsByRepoIDSince(e Engine, repoID, since int64) ([]*Comment, error) { func getCommentsByRepoIDSince(e Engine, repoID, since int64) ([]*Comment, error) {
comments := make([]*Comment, 0, 10) comments := make([]*Comment, 0, 10)
sess := e.Where("issue.repo_id = ?", repoID).Join("INNER", "issue", "issue.id = comment.issue_id", repoID).Asc("created_unix") sess := e.Where("issue.repo_id = ?", repoID).Join("INNER", "issue", "issue.id = comment.issue_id", repoID).Asc("comment.created_unix")
if since > 0 { if since > 0 {
sess.And("updated_unix >= ?", since) sess.And("comment.updated_unix >= ?", since)
} }
if err := sess.Find(&comments); err != nil { if err := sess.Find(&comments); err != nil {
return nil, err return nil, err

14
routes/api/v1/repo/issue_comment.go

@ -15,7 +15,12 @@ import (
func ListIssueComments(c *context.APIContext) { func ListIssueComments(c *context.APIContext) {
var since time.Time var since time.Time
if len(c.Query("since")) > 0 { if len(c.Query("since")) > 0 {
since, _ = time.Parse(time.RFC3339, c.Query("since")) var err error
since, err = time.Parse(time.RFC3339, c.Query("since"))
if err != nil {
c.Error(422, "", err)
return
}
} }
// comments,err:=models.GetCommentsByIssueIDSince(, since) // comments,err:=models.GetCommentsByIssueIDSince(, since)
@ -41,7 +46,12 @@ func ListIssueComments(c *context.APIContext) {
func ListRepoIssueComments(c *context.APIContext) { func ListRepoIssueComments(c *context.APIContext) {
var since time.Time var since time.Time
if len(c.Query("since")) > 0 { if len(c.Query("since")) > 0 {
since, _ = time.Parse(time.RFC3339, c.Query("since")) var err error
since, err = time.Parse(time.RFC3339, c.Query("since"))
if err != nil {
c.Error(422, "", err)
return
}
} }
comments, err := models.GetCommentsByRepoIDSince(c.Repo.Repository.ID, since.Unix()) comments, err := models.GetCommentsByRepoIDSince(c.Repo.Repository.ID, since.Unix())

2
templates/.VERSION

@ -1 +1 @@
0.11.23.0625 0.11.24.0627
Loading…
Cancel
Save