diff --git a/packages/nylas-core/models/shared/account.js b/packages/nylas-core/models/shared/account.js index 9a61101a9..da16219d3 100644 --- a/packages/nylas-core/models/shared/account.js +++ b/packages/nylas-core/models/shared/account.js @@ -12,7 +12,11 @@ module.exports = (sequelize, Sequelize) => { connectionCredentials: Sequelize.TEXT, syncPolicy: JSONType('syncPolicy'), syncError: JSONType('syncError', {defaultValue: null}), - firstSyncCompletion: Sequelize.INTEGER(14), + firstSyncCompletion: { + type: Sequelize.INTEGER(14), + allowNull: true, + defaultValue: null, + }, lastSyncCompletions: JSONARRAYType('lastSyncCompletions'), }, { classMethods: { diff --git a/packages/nylas-sync/sync-worker.js b/packages/nylas-sync/sync-worker.js index 8a7a9fd0f..51a8e9544 100644 --- a/packages/nylas-sync/sync-worker.js +++ b/packages/nylas-sync/sync-worker.js @@ -208,12 +208,12 @@ class SyncWorker { onSyncDidComplete() { const {afterSync} = this._account.syncPolicy; + const now = Date.now(); if (!this._account.firstSyncCompletion) { - this._account.firstSyncCompletion = Date.now() + this._account.firstSyncCompletion = now; } - const now = Date.now(); const syncGraphTimeLength = 60 * 30; // 30 minutes, should be the same as SyncGraph.config.timeLength let lastSyncCompletions = [].concat(this._account.lastSyncCompletions) lastSyncCompletions = [now, ...lastSyncCompletions]