update
This commit is contained in:
35
debug_categories.py
Normal file
35
debug_categories.py
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
from pymongo import MongoClient
|
||||
from datetime import datetime, timedelta
|
||||
import os
|
||||
|
||||
# Connect to MongoDB
|
||||
mongo_uri = os.getenv('MONGODB_URI', 'mongodb://mongodb:27017/')
|
||||
client = MongoClient(mongo_uri)
|
||||
db = client['munich_news']
|
||||
articles = db['articles']
|
||||
subscribers = db['subscribers']
|
||||
|
||||
print("--- Distinct Categories in Articles Collection ---")
|
||||
categories = articles.distinct('category')
|
||||
print(categories)
|
||||
|
||||
print("\n--- Recent Article Counts by Category (Last 24h) ---")
|
||||
yesterday = datetime.utcnow() - timedelta(hours=24)
|
||||
recent_articles = articles.find({'created_at': {'$gte': yesterday}})
|
||||
category_counts = {}
|
||||
for art in recent_articles:
|
||||
cat = art.get('category', 'unknown')
|
||||
category_counts[cat] = category_counts.get(cat, 0) + 1
|
||||
|
||||
for cat, count in category_counts.items():
|
||||
print(f"{cat}: {count}")
|
||||
|
||||
print("\n--- Subscriber Preferences ---")
|
||||
for sub in subscribers.find():
|
||||
print(f"Email: {sub.get('email')}, Categories: {sub.get('categories')}")
|
||||
|
||||
print("\n--- RSS Feeds ---")
|
||||
rss_feeds = db['rss_feeds']
|
||||
for feed in rss_feeds.find():
|
||||
print(f"Name: {feed.get('name')}, URL: {feed.get('url')}, Category: {feed.get('category')}, Active: {feed.get('active')}")
|
||||
Reference in New Issue
Block a user