Fix problem when database ID is not incremented as expected (#17229)

Although #17124 fixed the same issue for the feed, some other parts
with the same issue were found.

Co-authored-by: finga <finga@onders.org>
pull/17214/head^2
finga 3 years ago committed by GitHub
parent 21a784e94a
commit 67bc04fe21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      models/admin.go
  2. 2
      models/issue.go
  3. 2
      models/token.go

@ -107,7 +107,7 @@ func Notices(page, pageSize int) ([]*Notice, error) {
notices := make([]*Notice, 0, pageSize) notices := make([]*Notice, 0, pageSize)
return notices, db.GetEngine(db.DefaultContext). return notices, db.GetEngine(db.DefaultContext).
Limit(pageSize, (page-1)*pageSize). Limit(pageSize, (page-1)*pageSize).
Desc("id"). Desc("created_unix").
Find(&notices) Find(&notices)
} }

@ -843,7 +843,7 @@ func (issue *Issue) GetLastEventLabel() string {
func (issue *Issue) GetLastComment() (*Comment, error) { func (issue *Issue) GetLastComment() (*Comment, error) {
var c Comment var c Comment
exist, err := db.GetEngine(db.DefaultContext).Where("type = ?", CommentTypeComment). exist, err := db.GetEngine(db.DefaultContext).Where("type = ?", CommentTypeComment).
And("issue_id = ?", issue.ID).Desc("id").Get(&c) And("issue_id = ?", issue.ID).Desc("created_unix").Get(&c)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -161,7 +161,7 @@ func ListAccessTokens(opts ListAccessTokensOptions) ([]*AccessToken, error) {
sess = sess.Where("name=?", opts.Name) sess = sess.Where("name=?", opts.Name)
} }
sess = sess.Desc("id") sess = sess.Desc("created_unix")
if opts.Page != 0 { if opts.Page != 0 {
sess = db.SetSessionPagination(sess, &opts) sess = db.SetSessionPagination(sess, &opts)

Loading…
Cancel
Save