summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-14 02:40:23 -0500
committerUnknwon <u@gogs.io>2015-12-14 02:40:23 -0500
commit91789930bcc9d5796a1b06bdeb1402106c0d18d2 (patch)
treec2f38efca910d4df435deae7a668881720aaeb10
parentea375c0dcca118c8ac3c48ba569b025836ad5ccf (diff)
downloadgitea-91789930bcc9d5796a1b06bdeb1402106c0d18d2.tar.gz
gitea-91789930bcc9d5796a1b06bdeb1402106c0d18d2.zip
#2176 fix 500 on /watchers & /stars for pg
-rw-r--r--gogs.go2
-rw-r--r--models/repo.go18
-rw-r--r--templates/.VERSION2
3 files changed, 16 insertions, 6 deletions
diff --git a/gogs.go b/gogs.go
index e56fbf414e..80f2f4b517 100644
--- a/gogs.go
+++ b/gogs.go
@@ -18,7 +18,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
-const APP_VER = "0.8.3.1213"
+const APP_VER = "0.8.3.1214"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
diff --git a/models/repo.go b/models/repo.go
index 76e381600e..8b6731a72e 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1886,8 +1886,13 @@ func GetWatchers(repoID int64) ([]*Watch, error) {
// Repository.GetWatchers returns range of users watching given repository.
func (repo *Repository) GetWatchers(page int) ([]*User, error) {
users := make([]*User, 0, ItemsPerPage)
- return users, x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).
- Where("repo_id=?", repo.ID).Join("LEFT", "watch", "user.id=watch.user_id").Find(&users)
+ sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("watch.repo_id=?", repo.ID)
+ if setting.UsePostgreSQL {
+ sess = sess.Join("LEFT", "watch", `"user".id=watch.user_id`)
+ } else {
+ sess = sess.Join("LEFT", "watch", "user.id=watch.user_id")
+ }
+ return users, sess.Find(&users)
}
func notifyWatchers(e Engine, act *Action) error {
@@ -1969,8 +1974,13 @@ func IsStaring(uid, repoId int64) bool {
func (repo *Repository) GetStargazers(page int) ([]*User, error) {
users := make([]*User, 0, ItemsPerPage)
- return users, x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).
- Where("repo_id=?", repo.ID).Join("LEFT", "star", "user.id=star.uid").Find(&users)
+ sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("star.repo_id=?", repo.ID)
+ if setting.UsePostgreSQL {
+ sess = sess.Join("LEFT", "star", `"user".id=star.uid`)
+ } else {
+ sess = sess.Join("LEFT", "star", "user.id=star.uid")
+ }
+ return users, sess.Find(&users)
}
// ___________ __
diff --git a/templates/.VERSION b/templates/.VERSION
index d03366c022..32086d73d3 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.8.3.1213 \ No newline at end of file
+0.8.3.1214 \ No newline at end of file