Skip to content

Commit 46320f9

Browse files
authored
refactor notificationsForUser since xorm In support slice of customerize type (#956)
1 parent 0642cb3 commit 46320f9

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

models/notification.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,23 +189,20 @@ func NotificationsForUser(user *User, statuses []NotificationStatus, page, perPa
189189
return notificationsForUser(x, user, statuses, page, perPage)
190190
}
191191
func notificationsForUser(e Engine, user *User, statuses []NotificationStatus, page, perPage int) (notifications []*Notification, err error) {
192-
// FIXME: Xorm does not support aliases types (like NotificationStatus) on In() method
193-
s := make([]uint8, len(statuses))
194-
for i, status := range statuses {
195-
s[i] = uint8(status)
192+
if len(statuses) == 0 {
193+
return
196194
}
197195

198196
sess := e.
199197
Where("user_id = ?", user.ID).
200-
In("status", s).
198+
In("status", statuses).
201199
OrderBy("updated_unix DESC")
202200

203201
if page > 0 && perPage > 0 {
204202
sess.Limit(perPage, (page-1)*perPage)
205203
}
206204

207-
err = sess.
208-
Find(&notifications)
205+
err = sess.Find(&notifications)
209206
return
210207
}
211208

vendor/github.com/go-xorm/builder/cond_in.go

Lines changed: 20 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/vendor.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@
437437
"revisionTime": "2016-11-01T11:13:14Z"
438438
},
439439
{
440-
"checksumSHA1": "sDRC697KuCbpI+1i2VPhyqgAvjs=",
440+
"checksumSHA1": "Fh6Svimt+QyXHbaVxgSV7qwUHL8=",
441441
"path": "github.com/go-xorm/builder",
442-
"revision": "db75972580de4a7c6c20fff5b16a924c3de3fa12",
443-
"revisionTime": "2016-12-14T02:05:24Z"
442+
"revision": "9c357861b643b7dd1023551fdf116b8d42030146",
443+
"revisionTime": "2017-02-16T03:03:40Z"
444444
},
445445
{
446446
"checksumSHA1": "OCcksAYN5m0kc5yJF/Ba4VVHqeA=",

0 commit comments

Comments
 (0)