fix(sync): ranking dedup + copy logs over HTTP

- ranking.js: déduplique par (gencod, site) avant batchUpsert pour éviter
  "ON CONFLICT DO UPDATE command cannot affect row a second time"
- server.js: bouton "Copier les logs" utilise execCommand fallback quand
  navigator.clipboard indisponible (accès HTTP sans HTTPS)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Opus 4.6 committed 2026-03-19 12:06:27 +01:00
1 parent 5ce480ade3
commit e189cc3045
2 files changed
+22 -12

No files matched your search

+6 -1
View File
@@ -46,7 +46,12 @@ async function syncRanking(force) {
date_calcul_mag: r.DATE_CALCUL_MAG || null,
}));
const count = await batchUpsert(pg, 'ranking', rows, ['gencod', 'site'], COLS);
// Dédupliquer par (gencod, site) — garder la dernière occurrence
const seen = new Map();
for (const r of rows) seen.set(`${r.gencod}|${r.site}`, r);
const deduped = Array.from(seen.values());
const count = await batchUpsert(pg, 'ranking', deduped, ['gencod', 'site'], COLS);
await logSync(pg, 'ranking', count, 'ok');
console.log(`[ranking] ${count} lignes upsert`);
} catch (err) {