Files
graphs/fake-data.js
Cauê Faleiros e7f39a1e35
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m30s
feat: implement consistent 20-color mapping for visible products across dashboard charts
2026-05-07 11:28:37 -03:00

43 lines
1.4 KiB
JavaScript

// Clear previous data for a clean slate
const { Pool } = require('pg');
const pool = new Pool({ connectionString: 'postgres://graphuser:graphpassword@localhost:5432/graphdb' });
async function run() {
await pool.query('TRUNCATE TABLE orders RESTART IDENTITY;');
// Group 1: High Quantity, Low Price (Top 10 in Bar Chart, won't show in Pie Chart)
const group1 = Array.from({length: 10}, (_, i) => ({
Nome_Cliente: "Fake Client A" + i,
Data_Pedido: "06-05-2026",
Valor_Pedido: 100,
ID_Produto: "QA" + i,
Descricao_Produto: "Produto Muito Vendido " + i,
Quantidade: 1000 + i, // High sales
Valor_Unitario: 0.10 // Low revenue
}));
// Group 2: Low Quantity, High Price (Top 10 in Pie Chart, won't show in Bar Chart)
const group2 = Array.from({length: 10}, (_, i) => ({
Nome_Cliente: "Fake Client B" + i,
Data_Pedido: "06-05-2026",
Valor_Pedido: 10000,
ID_Produto: "QB" + i,
Descricao_Produto: "Produto Muito Caro " + i,
Quantidade: 1, // Low sales
Valor_Unitario: 10000 + i // High revenue
}));
const products = [...group1, ...group2];
const res = await fetch('http://localhost:3004/api/data', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-api-key': 'nexstar_secret_key_123' },
body: JSON.stringify(products)
});
console.log(res.status);
process.exit(0);
}
run();