diff --git a/scripts/check-db-now.js b/scripts/check-db-now.js new file mode 100644 index 0000000..e8c682e --- /dev/null +++ b/scripts/check-db-now.js @@ -0,0 +1,77 @@ +// Script pour voir EXACTEMENT ce qu'il y a dans la DB +const { getAll, initDatabase } = require('../config/database'); + +async function checkDB() { + console.log('\n==================== VERIFICATION DB RSS ====================\n'); + + try { + await initDatabase(); + + // Compter les flux + const feedsCount = await getAll('SELECT COUNT(*) as count FROM rss_feeds'); + console.log(`Flux RSS: ${feedsCount[0].count}\n`); + + // Lister les flux + const feeds = await getAll('SELECT id, title, url, enabled FROM rss_feeds'); + if (feeds.length > 0) { + console.log('Liste des flux:'); + feeds.forEach(f => { + console.log(` ${f.id}. ${f.title} (${f.enabled ? 'actif' : 'inactif'})`); + console.log(` ${f.url.substring(0, 80)}...`); + }); + console.log(''); + } + + // Compter les articles + const articlesCount = await getAll('SELECT COUNT(*) as count FROM rss_articles'); + console.log(`Articles: ${articlesCount[0].count}\n`); + + if (articlesCount[0].count > 0) { + // Compter par flux + const byFeed = await getAll(` + SELECT f.title, COUNT(a.id) as count, MAX(a.pub_date) as latest + FROM rss_feeds f + LEFT JOIN rss_articles a ON f.id = a.feed_id + GROUP BY f.id + `); + + console.log('Articles par flux:'); + byFeed.forEach(item => { + const latest = item.latest ? new Date(item.latest).toLocaleString('fr-FR') : 'aucun'; + console.log(` ${item.title}: ${item.count} articles`); + console.log(` Plus récent: ${latest}`); + }); + console.log(''); + + // Afficher les 10 derniers + const recent = await getAll(` + SELECT a.title, a.pub_date, f.title as feed_title + FROM rss_articles a + LEFT JOIN rss_feeds f ON a.feed_id = f.id + ORDER BY a.pub_date DESC + LIMIT 10 + `); + + console.log('10 derniers articles:'); + recent.forEach((article, i) => { + const date = new Date(article.pub_date); + const now = new Date(); + const diffHours = Math.round((now - date) / (1000 * 60 * 60)); + const isToday = date.toDateString() === now.toDateString(); + + console.log(`\n${i + 1}. ${article.title}`); + console.log(` Source: ${article.feed_title}`); + console.log(` Date: ${date.toLocaleString('fr-FR')} ${isToday ? '(AUJOURD\'HUI)' : `(il y a ${diffHours}h)`}`); + }); + } + + console.log('\n========================================================\n'); + + } catch (error) { + console.error('Erreur:', error); + } + + process.exit(0); +} + +checkDB(); diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index d41077b..5279f17 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -150,6 +150,15 @@ const Index = () => { } }, [navigate]); + // Auto-refresh des articles RSS toutes les 2 minutes + useEffect(() => { + const interval = setInterval(() => { + loadRssArticles(); + }, 2 * 60 * 1000); // 2 minutes (synchronisé avec le scheduler backend) + + return () => clearInterval(interval); + }, []); + const loadNotes = async () => { try { const fetchedNotes = await NotesService.getNotes();