changes needed in models

This commit is contained in:
6543 2020-03-11 22:13:20 +01:00
parent 05bb9d06da
commit f09dc25b0c
2 changed files with 7 additions and 9 deletions

View File

@ -1088,14 +1088,8 @@ func sortIssuesSession(sess *xorm.Session, sortType string, priorityRepoID int64
}
func (opts *IssuesOptions) setupSession(sess *xorm.Session) {
if opts.Page >= 0 && opts.PageSize > 0 {
var start int
if opts.Page == 0 {
start = 0
} else {
start = (opts.Page - 1) * opts.PageSize
}
sess.Limit(opts.PageSize, start)
if opts.Page != 0 {
opts.ListOptions.setSessionPagination(sess)
}
if len(opts.IssueIDs) > 0 {

View File

@ -103,7 +103,11 @@ func (opts *FindNotificationOptions) ToCond() builder.Cond {
// ToSession will convert the given options to a xorm Session by using the conditions from ToCond and joining with issue table if required
func (opts *FindNotificationOptions) ToSession(e Engine) *xorm.Session {
return opts.setSessionPagination(e.Where(opts.ToCond()))
sess := e.Where(opts.ToCond())
if opts.Page != 0 {
sess = opts.setSessionPagination(sess)
}
return sess
}
func getNotifications(e Engine, options FindNotificationOptions) (nl NotificationList, err error) {