diff --git a/core/server/services/email-analytics/email-analytics.js b/core/server/services/email-analytics/email-analytics.js index 28b5083745..5fed5351d1 100644 --- a/core/server/services/email-analytics/email-analytics.js +++ b/core/server/services/email-analytics/email-analytics.js @@ -22,8 +22,8 @@ class EmailAnalyticsService { async fetchAll() { const result = new EventProcessingResult(); - const emailCount = await this.db.knex('emails').count(); - if (emailCount <= 0) { + const [emailCount] = await this.db.knex('emails').count('id as count'); + if (emailCount && emailCount.count <= 0) { debug('fetchAll: skipping - no emails to track'); return result; } @@ -43,8 +43,8 @@ class EmailAnalyticsService { const result = new EventProcessingResult(); const lastTimestamp = await this.getLastSeenEventTimestamp(); - const emailCount = await this.db.knex('emails').count(); - if (emailCount <= 0) { + const [emailCount] = await this.db.knex('emails').count('id as count'); + if (emailCount && emailCount.count <= 0) { debug('fetchLatest: skipping - no emails to track'); return result; }