From 249fd4f06aa6efb59e9e8a5580462b600c8e19e3 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 1 Dec 2020 15:01:08 +0000 Subject: [PATCH] Fixed email count check in email-analytics service no issue - raw knex `.count()` does not return a straight number, we need to handle an array of rowDataPacket objects --- core/server/services/email-analytics/email-analytics.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; }