Fixed milestone query for imported members not using correct date

refs https://www.notion.so/ghost/Marketing-Milestone-email-campaigns-1d2c9dee3cfa4029863edb16092ad5c4?pvs=4

- I was passing in the days threshold of 7 to compare with the `created_at` value instead of creating an actual new data to compare
This commit is contained in:
Aileen Nowak 2023-02-23 13:12:12 +02:00 committed by Aileen Booker
parent 9852c21ec5
commit 314b88cfb5

View File

@ -31,10 +31,13 @@ module.exports = class MilestoneQueries {
* @returns {Promise<boolean>}
*/
async hasImportedMembersInPeriod() {
const importedThreshold = new Date();
importedThreshold.setDate(importedThreshold.getDate() - MIN_DAYS_SINCE_IMPORTED);
const [hasImportedMembers] = await this.#db.knex('members_subscribe_events')
.count('id as count')
.where('source', '=', 'import')
.where('created_at', '>=', MIN_DAYS_SINCE_IMPORTED);
.where('created_at', '>=', importedThreshold);
return hasImportedMembers?.count > 0;
}