mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 11:55:22 +02:00
fix: logic to show BSR improvements (rank drops) in green
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user