34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
import { createConnection } from 'mysql2/promise';
|
|
import { config } from 'dotenv';
|
|
config();
|
|
|
|
const conn = await createConnection(process.env.DATABASE_URL);
|
|
|
|
// 1. Voir les doublons
|
|
const [doublons] = await conn.execute(
|
|
'SELECT annee, libelle, COUNT(*) as cnt FROM opex_postes GROUP BY annee, libelle HAVING cnt > 1 ORDER BY cnt DESC LIMIT 30'
|
|
);
|
|
console.log('=== Doublons (annee, libelle) ===');
|
|
console.table(doublons);
|
|
|
|
// 2. Total par année
|
|
const [totaux] = await conn.execute(
|
|
'SELECT annee, COUNT(*) as cnt FROM opex_postes GROUP BY annee ORDER BY annee'
|
|
);
|
|
console.log('=== Total postes par année ===');
|
|
console.table(totaux);
|
|
|
|
// 3. Libellés qui ressemblent à des catégories (parasites)
|
|
const [parasites] = await conn.execute(
|
|
`SELECT id, annee, libelle, categorie FROM opex_postes
|
|
WHERE libelle IN ('Infogérance','Sécurité','Téléphonie','App global','App HEP','App SMR',
|
|
'Applicatifs communs','Applicatifs PA','Applicatifs HEP','Applicatifs SMR','Nouveautés','TOTAL',
|
|
'Ventilation cout','Ventilation coût')
|
|
OR libelle REGEXP '^(total|ventilation|répartition)'
|
|
ORDER BY annee, libelle`
|
|
);
|
|
console.log('=== Libellés parasites en BDD ===');
|
|
console.table(parasites);
|
|
|
|
await conn.end();
|