summaryrefslogtreecommitdiffstats
path: root/models/notification.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-02-16 12:07:00 +0800
committerGitHub <noreply@github.com>2017-02-16 12:07:00 +0800
commit46320f9630087e010a31ab580294cc9137eb865f (patch)
tree99997f1335e1f6ee2963045fb90462322e44f155 /models/notification.go
parent0642cb330cbdb58632d6b7b5831200ff339bba8a (diff)
downloadgitea-46320f9630087e010a31ab580294cc9137eb865f.tar.gz
gitea-46320f9630087e010a31ab580294cc9137eb865f.zip
refactor notificationsForUser since xorm In support slice of customerize type (#956)
Diffstat (limited to 'models/notification.go')
-rw-r--r--models/notification.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/models/notification.go b/models/notification.go
index 7ef8f058ce..bba662c06c 100644
--- a/models/notification.go
+++ b/models/notification.go
@@ -189,23 +189,20 @@ func NotificationsForUser(user *User, statuses []NotificationStatus, page, perPa
return notificationsForUser(x, user, statuses, page, perPage)
}
func notificationsForUser(e Engine, user *User, statuses []NotificationStatus, page, perPage int) (notifications []*Notification, err error) {
- // FIXME: Xorm does not support aliases types (like NotificationStatus) on In() method
- s := make([]uint8, len(statuses))
- for i, status := range statuses {
- s[i] = uint8(status)
+ if len(statuses) == 0 {
+ return
}
sess := e.
Where("user_id = ?", user.ID).
- In("status", s).
+ In("status", statuses).
OrderBy("updated_unix DESC")
if page > 0 && perPage > 0 {
sess.Limit(perPage, (page-1)*perPage)
}
- err = sess.
- Find(&notifications)
+ err = sess.Find(&notifications)
return
}