mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 11:55:01 +03:00
Updated email event fetching to stop when begin and end are the same (#16326)
no issue Optimization that makes sure we stop fetching when it is no longer needed.
This commit is contained in:
parent
3ded0bbee8
commit
89ababb71f
@ -25,6 +25,13 @@ describe('EmailEventStorage', function () {
|
||||
let membersService;
|
||||
|
||||
before(async function () {
|
||||
// Stub queries before boot
|
||||
const queries = require('../../../../core/server/services/email-analytics/lib/queries');
|
||||
sinon.stub(queries, 'getLastSeenEventTimestamp').callsFake(async function () {
|
||||
// This is required because otherwise the last event timestamp will be now, and that is too close to NOW to start fetching new events
|
||||
return new Date(2000, 0, 1);
|
||||
});
|
||||
|
||||
agent = await agentProvider.getAdminAPIAgent();
|
||||
await fixtureManager.init('newsletters', 'members:newsletters', 'members:emails');
|
||||
await agent.loginAsOwner();
|
||||
|
@ -76,10 +76,10 @@ module.exports = class EmailAnalyticsService {
|
||||
const begin = await this.getLastEventTimestamp();
|
||||
const end = new Date(Date.now() - FETCH_LATEST_END_MARGIN_MS); // ALways stop at x minutes ago to give Mailgun a bit more time to stabilize storage
|
||||
|
||||
if (end < begin) {
|
||||
if (end <= begin) {
|
||||
// Skip for now
|
||||
logging.info('[EmailAnalytics] Skipping fetchLatest because end (' + end + ') is before begin (' + begin + ')');
|
||||
//return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create the fetch data object if it doesn't exist yet
|
||||
@ -109,7 +109,7 @@ module.exports = class EmailAnalyticsService {
|
||||
)
|
||||
);
|
||||
|
||||
if (end < begin) {
|
||||
if (end <= begin) {
|
||||
// Skip for now
|
||||
logging.info('[EmailAnalytics] Skipping fetchMissing because end (' + end + ') is before begin (' + begin + ')');
|
||||
return 0;
|
||||
@ -178,9 +178,9 @@ module.exports = class EmailAnalyticsService {
|
||||
begin = this.#fetchScheduledData.lastEventTimestamp;
|
||||
}
|
||||
|
||||
if (end < begin) {
|
||||
if (end <= begin) {
|
||||
// Skip for now
|
||||
logging.info('[EmailAnalytics] Skipping fetchScheduled because end is before begin');
|
||||
logging.info('[EmailAnalytics] Ending fetchScheduled because end is before begin');
|
||||
this.#fetchScheduledData = null;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user