Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,23 @@ export class DomainWarmingService {
*/
async getWarmupLimit(emailCount: number): Promise<number> {
const day = await this.#getDaysSinceFirstEmail();

let limit = 0;

if (day >= this.#warmupConfig.totalDays) {
return Infinity;
// Max limit if we're after the warm-up period
limit = Infinity;
} else {
// Interpolate the warmup amount
limit = Math.round(
this.#warmupConfig.start *
Math.pow(
this.#warmupConfig.end / this.#warmupConfig.start,
day / (this.#warmupConfig.totalDays - 1)
)
);
}

const limit = Math.round(
this.#warmupConfig.start *
Math.pow(
this.#warmupConfig.end / this.#warmupConfig.start,
day / (this.#warmupConfig.totalDays - 1)
)
);

return Math.min(emailCount, limit);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe('Domain Warming Service', function () {
}
});

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

const result = await service.getWarmupLimit(1000000);
assert.equal(result, Infinity);
assert.equal(result, 1000000);
});

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

const result = await service.getWarmupLimit(1000000);
assert.equal(result, Infinity);
assert.equal(result, 1000000);
});
});
});
Loading