accumulate stock deltas before campaigns
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 52s

This commit is contained in:
Cauê Faleiros
2026-05-27 16:14:09 -03:00
parent 72ded82ec7
commit 5e0bb1d83a
2 changed files with 43 additions and 15 deletions

View File

@@ -2,7 +2,7 @@ const { pool } = require('../db');
const { normalizeStockPayload } = require('../mappers/stockMapper');
const { enqueueStockCampaignItem } = require('./campaignService');
const CAMPAIGN_DELTA_THRESHOLD = 100;
const POSITIVE_STOCK_DELTA_THRESHOLD = 1;
const listStock = async () => {
const result = await pool.query('SELECT * FROM stock');
@@ -36,7 +36,7 @@ const upsertStockItems = async (payload) => {
item.deltaEstoque
]);
if (item.deltaEstoque >= CAMPAIGN_DELTA_THRESHOLD) {
if (item.deltaEstoque >= POSITIVE_STOCK_DELTA_THRESHOLD) {
await enqueueStockCampaignItem(client, item);
}
}