0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Adjusted email jobs registration to check for emails newer than 30 days

no issue

- if emails are older than 30 days we wouldn't be able to fetch any analytics for them and if a site used emails in the past but is no longer using them it doesn't make sense to keep potentially expensive background worker threads spinning up
This commit is contained in:
Kevin Ansfield 2020-12-02 12:13:54 +00:00
parent 947603d0e3
commit 92ef83c61a

View file

@ -14,7 +14,10 @@ module.exports = {
) {
// don't register email analytics job if we have no emails,
// processer usage from many sites spinning up threads can be high
const emailCount = await models.Email.count();
const emailCount = await models.Email
.where('status', 'submitted')
.where('created_at', '>', moment.utc().subtract(30, 'days').toDate())
.count();
if (emailCount > 0) {
// use a random seconds value to avoid spikes to external APIs on the minute