update
This commit is contained in:
@@ -224,6 +224,43 @@ def send_newsletter():
|
||||
}), 500
|
||||
|
||||
|
||||
@admin_bp.route('/api/admin/recent-articles', methods=['GET'])
|
||||
def get_recent_articles():
|
||||
"""Get recently summarized articles"""
|
||||
try:
|
||||
from database import articles_collection
|
||||
|
||||
# Get last 10 articles with summaries, sorted by when they were summarized
|
||||
articles = list(articles_collection.find(
|
||||
{'summary': {'$exists': True, '$ne': None}},
|
||||
{
|
||||
'title': 1,
|
||||
'title_en': 1,
|
||||
'source': 1,
|
||||
'category': 1,
|
||||
'summarized_at': 1,
|
||||
'created_at': 1,
|
||||
'summary_word_count': 1,
|
||||
'_id': 0
|
||||
}
|
||||
).sort('summarized_at', -1).limit(10))
|
||||
|
||||
# Convert datetime to ISO format
|
||||
for article in articles:
|
||||
if 'summarized_at' in article and article['summarized_at']:
|
||||
article['summarized_at'] = article['summarized_at'].isoformat()
|
||||
if 'created_at' in article and article['created_at']:
|
||||
article['created_at'] = article['created_at'].isoformat()
|
||||
|
||||
return jsonify({
|
||||
'articles': articles,
|
||||
'total': len(articles)
|
||||
}), 200
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
|
||||
@admin_bp.route('/api/admin/stats', methods=['GET'])
|
||||
def get_stats():
|
||||
"""Get system statistics"""
|
||||
|
||||
Reference in New Issue
Block a user