Skip to content

Commit 5ea7299

Browse files
committed
fix: only bill inserted and updated records
1 parent 2a4c3ee commit 5ea7299

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/records/lib/models/records.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,12 @@ export async function upsert({
405405
// A record is billed only once per month. ie:
406406
// - If a record is inserted, it is billed
407407
// - If a record is updated, it is billed if it has not been billed yet during the current month
408-
// - If a record is undeleted, it is billed if it has not been billed yet during the current month
409-
// - If a record is deleted, it is billed if it has not been billed yet during the current month
408+
// - If a record is undeleted, it is not billed
409+
// - If a record is deleted, it is not billed
410410

411411
if (softDelete) {
412412
const deleted = res.filter((r) => r.status === 'deleted');
413413
summary.deletedKeys?.push(...deleted.map((r) => r.external_id));
414-
summary.billedKeys.push(...billable(deleted).map((r) => r.external_id));
415414
} else {
416415
const undeletedRes = res.filter((r) => r.status === 'undeleted');
417416
const changedRes = res.filter((r) => r.status === 'changed');
@@ -420,7 +419,7 @@ export async function upsert({
420419
const undeletedKeys = undeletedRes.map((r) => r.external_id);
421420
const addedKeys = insertedKeys.concat(undeletedKeys);
422421
const updatedKeys = changedRes.map((r) => r.external_id);
423-
const billableKeys = [...insertedKeys, ...billable([...changedRes, ...undeletedRes]).map((r) => r.external_id)];
422+
const billableKeys = [...insertedKeys, ...billable(changedRes).map((r) => r.external_id)];
424423

425424
summary.addedKeys.push(...addedKeys);
426425
summary.updatedKeys.push(...updatedKeys);

0 commit comments

Comments
 (0)