summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorAndrey Nering <andrey.nering@gmail.com>2017-01-05 11:53:01 -0200
committerGitHub <noreply@github.com>2017-01-05 11:53:01 -0200
commit79d527195d98d74867a067ce93a4dace2b86d2bb (patch)
tree0dd577f8b0f28c95a7d66def7d321e3b4e65f2c3 /models
parent9d1bc9aac88bda13e4b9319ab915bca1b65521f6 (diff)
parentb354cf362ec432533da4384d4ee0c32283b7089f (diff)
downloadgitea-79d527195d98d74867a067ce93a4dace2b86d2bb.tar.gz
gitea-79d527195d98d74867a067ce93a4dace2b86d2bb.zip
Merge pull request #539 from andreynering/notifications-step-2
Notifications - Step 2
Diffstat (limited to 'models')
-rw-r--r--models/notification.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/models/notification.go b/models/notification.go
index 69f96bb5e6..e2460e8369 100644
--- a/models/notification.go
+++ b/models/notification.go
@@ -182,14 +182,20 @@ func getIssueNotification(e Engine, userID, issueID int64) (*Notification, error
}
// NotificationsForUser returns notifications for a given user and status
-func NotificationsForUser(user *User, status NotificationStatus) ([]*Notification, error) {
- return notificationsForUser(x, user, status)
+func NotificationsForUser(user *User, status NotificationStatus, page, perPage int) ([]*Notification, error) {
+ return notificationsForUser(x, user, status, page, perPage)
}
-func notificationsForUser(e Engine, user *User, status NotificationStatus) (notifications []*Notification, err error) {
- err = e.
+func notificationsForUser(e Engine, user *User, status NotificationStatus, page, perPage int) (notifications []*Notification, err error) {
+ sess := e.
Where("user_id = ?", user.ID).
And("status = ?", status).
- OrderBy("updated_unix DESC").
+ OrderBy("updated_unix DESC")
+
+ if page > 0 && perPage > 0 {
+ sess.Limit(perPage, (page-1)*perPage)
+ }
+
+ err = sess.
Find(&notifications)
return
}