Skip to content

Commit 67bc04f

Browse files
fingafinga
and
finga
authored
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>
1 parent 21a784e commit 67bc04f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

models/admin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func Notices(page, pageSize int) ([]*Notice, error) {
107107
notices := make([]*Notice, 0, pageSize)
108108
return notices, db.GetEngine(db.DefaultContext).
109109
Limit(pageSize, (page-1)*pageSize).
110-
Desc("id").
110+
Desc("created_unix").
111111
Find(&notices)
112112
}
113113

models/issue.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ func (issue *Issue) GetLastEventLabel() string {
843843
func (issue *Issue) GetLastComment() (*Comment, error) {
844844
var c Comment
845845
exist, err := db.GetEngine(db.DefaultContext).Where("type = ?", CommentTypeComment).
846-
And("issue_id = ?", issue.ID).Desc("id").Get(&c)
846+
And("issue_id = ?", issue.ID).Desc("created_unix").Get(&c)
847847
if err != nil {
848848
return nil, err
849849
}

models/token.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func ListAccessTokens(opts ListAccessTokensOptions) ([]*AccessToken, error) {
161161
sess = sess.Where("name=?", opts.Name)
162162
}
163163

164-
sess = sess.Desc("id")
164+
sess = sess.Desc("created_unix")
165165

166166
if opts.Page != 0 {
167167
sess = db.SetSessionPagination(sess, &opts)

0 commit comments

Comments
 (0)