mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 11:05:23 +02:00
51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
import XLSX from 'xlsx';
|
|||
|
|
import { readFileSync } from 'fs';
|
||
|
|
import { processAdsExcel } from './services/dataProcessor';
|
||
|
|
|
||
|
|
async function run() {
|
||
|
|
const buf = readFileSync('/tmp/Ads-Weekly.xlsx').buffer;
|
||
|
|
const adsData = await processAdsExcel(buf);
|
||
|
|
|
||
|
|
// Show ALL INKEE DE ads with their cost/salesAds
|
||
|
|
const inkeeDE = adsData.filter(a =>
|
||
|
|
a.asin.toUpperCase().startsWith('B0CQ') &&
|
||
|
|
a.country === 'Amazon DE'
|
||
|
|
);
|
||
|
|
|
||
|
|
console.log('=== ALL INKEE DE ADS RECORDS ===');
|
||
|
|
console.log('Count:', inkeeDE.length);
|
||
|
|
|
||
|
|
// Group by ASIN
|
||
|
|
const byAsin = new Map<string, any[]>();
|
||
|
|
for (const a of inkeeDE) {
|
||
|
|
const list = byAsin.get(a.asin) || [];
|
||
|
|
list.push(a);
|
||
|
|
byAsin.set(a.asin, list);
|
||
|
|
}
|
||
|
|
|
||
|
|
for (const [asin, records] of byAsin.entries()) {
|
||
|
|
const totalCost = records.reduce((s, r) => s + r.cost, 0);
|
||
|
|
const totalSales = records.reduce((s, r) => s + r.attributedSales30d, 0);
|
||
|
|
const totalClicks = records.reduce((s, r) => s + r.clicks, 0);
|
||
|
|
|
||
|
|
console.log(`\nASIN: ${asin}`);
|
||
|
|
console.log(` Records: ${records.length} | TotalCost: ${totalCost.toFixed(2)} | TotalSales: ${totalSales.toFixed(2)} | TotalClicks: ${totalClicks}`);
|
||
|
|
|
||
|
|
for (const r of records) {
|
||
|
|
console.log(` Year:${r.year} Week:${r.week} cost:${r.cost} salesAds:${r.attributedSales30d} clicks:${r.clicks}`);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Show acos calculation possibility
|
||
|
|
const withCost = inkeeDE.filter(a => a.cost > 0);
|
||
|
|
console.log('\nINKEE DE records with cost > 0:', withCost.length);
|
||
|
|
|
||
|
|
// What week numbers are we talking about?
|
||
|
|
// INKEE DE experiment likely runs in Jan-Feb 2026 or similar
|
||
|
|
// Week 1 of 2026 = Jan 5-11, Week 6 = Feb 9-15, Week 8 = Feb 23 - Mar 1
|
||
|
|
console.log('\nWeek 1 2026 start (Sun):', new Date(2026, 0, 4).toISOString().split('T')[0]);
|
||
|
|
console.log('Week 8 2026 start (Sun):', new Date(2026, 0, 4 + 7 * 7).toISOString().split('T')[0]);
|
||
|
|
}
|
||
|
|
|
||
|
|
run().catch(console.error);
|