mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 14:25:23 +02:00
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
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);
|