0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

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
This commit is contained in:
Kevin Ansfield 2020-12-01 15:01:08 +00:00
parent 0e46898aaa
commit 249fd4f06a

View file

@ -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;
}