0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00

Fixed random test failure due to member newsletter ordering (#16024)

fixes https://github.com/TryGhost/Team/issues/2365

The newsletters relation of a member was not sorted. This is fixed now,
so we have consistent results in the test snapshots.
This commit is contained in:
Simon Backx 2023-01-03 09:43:41 +01:00 committed by GitHub
parent c0b700147e
commit 211de82a8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,7 +50,7 @@ const Member = ghostBookshelf.Model.extend({
replacement: 'emails.post_id',
// Currently we cannot expand on values such as null or a string in mongo-knex
// But the line below is essentially the same as: `email_recipients.opened_at:-null`
expansion: 'email_recipients.opened_at:>=0'
expansion: 'email_recipients.opened_at:>=0'
}];
},
@ -165,6 +165,7 @@ const Member = ghostBookshelf.Model.extend({
newsletters() {
return this.belongsToMany('Newsletter', 'members_newsletters', 'member_id', 'newsletter_id')
.query('orderBy', 'newsletters.sort_order', 'ASC')
.query((qb) => {
// avoids bookshelf adding a `DISTINCT` to the query
// we know the result set will already be unique and DISTINCT hurts query performance