fix: logic to show BSR improvements (rank drops) in green

This commit is contained in:
Christian Vidal Wolf
2026-03-10 14:04:20 +01:00
parent c15642d62d
commit 74d92b83b5
14 changed files with 924 additions and 1 deletions
+42
View File
@@ -0,0 +1,42 @@
import XLSX from 'xlsx';
import { readFileSync } from 'fs';
import { processAdsExcel, mergeSalesAndAdsData } from './services/dataProcessor';
async function run() {
const buf = readFileSync('/tmp/Ads-Weekly.xlsx').buffer;
const adsData = await processAdsExcel(buf);
// Simulate with empty sales - ads-only records
const merged = mergeSalesAndAdsData([], adsData);
console.log('Total merged records (ads-only):', merged.length);
// Find INKEE DE ads-only records
const inkeeDE = merged.filter(m =>
m.asin.startsWith('B0CQ') &&
(m.marketplace || m.customer || '').includes('DE')
);
console.log('\nINKEE DE in merged:', inkeeDE.length);
for (const r of inkeeDE) {
console.log(` ASIN:${r.asin} year:${r.year} week:${r.week} marketplace:"${r.marketplace}" customer:"${r.customer}" cost:${r.cost} salesAds:${r.salesAds} clicks:${r.clicks}`);
}
// Now test the aggregation (just for "DE" marketplace filter)
const asinSet = new Set(['B0CQ247T2V', 'B0CQTLZRCV']);
for (const marketplace of ['DE', 'Amazon DE', 'de', 'amazon de', '']) {
const matching = inkeeDE.filter(r => {
const mkt = (r.marketplace || r.customer || '').toLowerCase();
if (!marketplace || marketplace === 'All') return true;
return mkt.includes(marketplace.toLowerCase());
});
console.log(`\nFilter mkt="${marketplace}": ${matching.length} matching INKEE DE records`);
if (matching.length > 0) {
const totalCost = matching.reduce((s, r) => s + (r.cost || 0), 0);
console.log(` Total cost: ${totalCost.toFixed(2)}`);
}
}
}
run().catch(console.error);