Update app.py
Browse files
app.py
CHANGED
|
@@ -637,6 +637,105 @@ def clear_all_tasks():
|
|
| 637 |
|
| 638 |
return jsonify({'success': True})
|
| 639 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 640 |
# =======================
|
| 641 |
# Initialisation
|
| 642 |
# =======================
|
|
|
|
| 637 |
|
| 638 |
return jsonify({'success': True})
|
| 639 |
|
| 640 |
+
|
| 641 |
+
# Ajouter cette route dans votre fichier app.py
|
| 642 |
+
|
| 643 |
+
@app.route('/stats')
|
| 644 |
+
def system_stats():
|
| 645 |
+
"""Affiche les statistiques du système"""
|
| 646 |
+
conn = get_db_connection()
|
| 647 |
+
|
| 648 |
+
# Nombre total de résumés
|
| 649 |
+
total = conn.execute('SELECT COUNT(*) as count FROM tasks').fetchone()['count']
|
| 650 |
+
|
| 651 |
+
# Nombre de résumés réussis
|
| 652 |
+
completed = conn.execute(
|
| 653 |
+
'SELECT COUNT(*) as count FROM tasks WHERE status = ?',
|
| 654 |
+
('completed',)
|
| 655 |
+
).fetchone()['count']
|
| 656 |
+
|
| 657 |
+
# Nombre de résumés en cours
|
| 658 |
+
processing = conn.execute(
|
| 659 |
+
'SELECT COUNT(*) as count FROM tasks WHERE status IN (?, ?)',
|
| 660 |
+
('pending', 'processing')
|
| 661 |
+
).fetchone()['count']
|
| 662 |
+
|
| 663 |
+
# Nombre de résumés échoués
|
| 664 |
+
failed = conn.execute(
|
| 665 |
+
'SELECT COUNT(*) as count FROM tasks WHERE status = ?',
|
| 666 |
+
('failed',)
|
| 667 |
+
).fetchone()['count']
|
| 668 |
+
|
| 669 |
+
# Statistiques par type de résumé
|
| 670 |
+
by_type = conn.execute('''
|
| 671 |
+
SELECT summary_type, COUNT(*) as count
|
| 672 |
+
FROM tasks
|
| 673 |
+
WHERE status = 'completed'
|
| 674 |
+
GROUP BY summary_type
|
| 675 |
+
''').fetchall()
|
| 676 |
+
|
| 677 |
+
# Statistiques par source
|
| 678 |
+
by_source = conn.execute('''
|
| 679 |
+
SELECT source_type, COUNT(*) as count
|
| 680 |
+
FROM tasks
|
| 681 |
+
WHERE status = 'completed'
|
| 682 |
+
GROUP BY source_type
|
| 683 |
+
''').fetchall()
|
| 684 |
+
|
| 685 |
+
conn.close()
|
| 686 |
+
|
| 687 |
+
# Créer le HTML minimaliste
|
| 688 |
+
html = f'''<!DOCTYPE html>
|
| 689 |
+
<html>
|
| 690 |
+
<head>
|
| 691 |
+
<meta charset="utf-8">
|
| 692 |
+
<title>Statistiques Système</title>
|
| 693 |
+
</head>
|
| 694 |
+
<body>
|
| 695 |
+
<h1>Statistiques du Système</h1>
|
| 696 |
+
|
| 697 |
+
<h2>Vue d'ensemble</h2>
|
| 698 |
+
<ul>
|
| 699 |
+
<li>Total de résumés : {total}</li>
|
| 700 |
+
<li>Résumés réussis : {completed}</li>
|
| 701 |
+
<li>En cours : {processing}</li>
|
| 702 |
+
<li>Échoués : {failed}</li>
|
| 703 |
+
</ul>
|
| 704 |
+
|
| 705 |
+
<h2>Par type de résumé</h2>
|
| 706 |
+
<ul>
|
| 707 |
+
'''
|
| 708 |
+
|
| 709 |
+
for row in by_type:
|
| 710 |
+
html += f' <li>{row["summary_type"].capitalize()} : {row["count"]}</li>\n'
|
| 711 |
+
|
| 712 |
+
if not by_type:
|
| 713 |
+
html += ' <li>Aucune donnée</li>\n'
|
| 714 |
+
|
| 715 |
+
html += ''' </ul>
|
| 716 |
+
|
| 717 |
+
<h2>Par source</h2>
|
| 718 |
+
<ul>
|
| 719 |
+
'''
|
| 720 |
+
|
| 721 |
+
for row in by_source:
|
| 722 |
+
source_name = 'Fichier' if row['source_type'] == 'file' else 'YouTube'
|
| 723 |
+
html += f' <li>{source_name} : {row["count"]}</li>\n'
|
| 724 |
+
|
| 725 |
+
if not by_source:
|
| 726 |
+
html += ' <li>Aucune donnée</li>\n'
|
| 727 |
+
|
| 728 |
+
html += ''' </ul>
|
| 729 |
+
|
| 730 |
+
<p><a href="/">Retour à l'accueil</a></p>
|
| 731 |
+
</body>
|
| 732 |
+
</html>'''
|
| 733 |
+
|
| 734 |
+
return html
|
| 735 |
+
|
| 736 |
+
|
| 737 |
+
|
| 738 |
+
|
| 739 |
# =======================
|
| 740 |
# Initialisation
|
| 741 |
# =======================
|