Fixed posts without open rate being ordered in reverse

refs https://github.com/TryGhost/Ghost/issues/12420

- adds additional sorting by post creation date so that posts below those with an open rate appear in a more useful order
This commit is contained in:
Kevin Ansfield 2020-12-04 13:12:14 +00:00
parent 7038f381b3
commit 7c57ffd6a6

View File

@ -109,8 +109,11 @@ Post = ghostBookshelf.Model.extend({
// *1.0 is needed on one of the columns to prevent sqlite from // *1.0 is needed on one of the columns to prevent sqlite from
// performing integer division rounding and always giving 0. // performing integer division rounding and always giving 0.
// Order by emails.track_opens desc first so we always tracked emails // Order by emails.track_opens desc first so we always tracked emails
// before untracked emails in the posts list // before untracked emails in the posts list.
orderByRaw: `emails.track_opens desc, emails.opened_count * 1.0 / emails.email_count * 100 ${direction}`, orderByRaw: `
emails.track_opens desc,
emails.opened_count * 1.0 / emails.email_count * 100 ${direction},
posts.created_at desc`,
eagerLoad: 'email.open_rate' eagerLoad: 'email.open_rate'
}; };
} }