Skip to content

Commit 3830882

Browse files
committed
Fixed domain warming when warming has completed
ref INC-258
1 parent 05be0c1 commit 3830882

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

ghost/core/core/server/services/email-service/domain-warming-service.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,23 @@ export class DomainWarmingService {
6969
*/
7070
async getWarmupLimit(emailCount: number): Promise<number> {
7171
const day = await this.#getDaysSinceFirstEmail();
72+
73+
let limit = 0;
74+
7275
if (day >= this.#warmupConfig.totalDays) {
73-
return Infinity;
76+
// Max limit if we're after the warm-up period
77+
limit = Infinity;
78+
} else {
79+
// Interpolate the warmup amount
80+
limit = Math.round(
81+
this.#warmupConfig.start *
82+
Math.pow(
83+
this.#warmupConfig.end / this.#warmupConfig.start,
84+
day / (this.#warmupConfig.totalDays - 1)
85+
)
86+
);
7487
}
7588

76-
const limit = Math.round(
77-
this.#warmupConfig.start *
78-
Math.pow(
79-
this.#warmupConfig.end / this.#warmupConfig.start,
80-
day / (this.#warmupConfig.totalDays - 1)
81-
)
82-
);
83-
8489
return Math.min(emailCount, limit);
8590
}
8691
}

ghost/core/test/unit/server/services/email-service/domain-warming-service.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ describe('Domain Warming Service', function () {
245245
}
246246
});
247247

248-
it('should return Infinity after warmup period is complete', async function () {
248+
it('should return emailCount after warmup period is complete', async function () {
249249
// After 42 days, warmup is complete
250250
Email = createModelClass({
251251
findAll: [{
@@ -260,10 +260,10 @@ describe('Domain Warming Service', function () {
260260
});
261261

262262
const result = await service.getWarmupLimit(1000000);
263-
assert.equal(result, Infinity);
263+
assert.equal(result, 1000000);
264264
});
265265

266-
it('should return Infinity well after warmup period is complete', async function () {
266+
it('should return emailCount well after warmup period is complete', async function () {
267267
// After 100 days, warmup should definitely be complete
268268
Email = createModelClass({
269269
findAll: [{
@@ -278,7 +278,7 @@ describe('Domain Warming Service', function () {
278278
});
279279

280280
const result = await service.getWarmupLimit(1000000);
281-
assert.equal(result, Infinity);
281+
assert.equal(result, 1000000);
282282
});
283283
});
284284
});

0 commit comments

Comments
 (0)