update
This commit is contained in:
@@ -166,9 +166,13 @@ def get_latest_articles_by_categories(categories=None, articles_per_category=3,
|
||||
# Get cluster summaries collection
|
||||
cluster_summaries_collection = db['cluster_summaries']
|
||||
|
||||
# If no categories specified, get all available categories
|
||||
# If no categories specified, get all available categories from database
|
||||
if categories is None:
|
||||
categories = ['general', 'local', 'sports', 'science']
|
||||
# Dynamically get categories from articles collection
|
||||
categories = list(articles_collection.distinct('category'))
|
||||
if not categories:
|
||||
# Fallback to default categories if no articles exist yet
|
||||
categories = ['general', 'local', 'sports', 'science']
|
||||
|
||||
articles = []
|
||||
processed_clusters = set()
|
||||
@@ -329,7 +333,8 @@ def get_latest_articles_by_categories(categories=None, articles_per_category=3,
|
||||
|
||||
# Reconstruct non-clustered list with shuffled articles
|
||||
non_clustered = []
|
||||
for cat in ['general', 'local', 'sports', 'science']:
|
||||
# Use all categories that exist in the articles
|
||||
for cat in sorted(by_category.keys()):
|
||||
non_clustered.extend(by_category[cat])
|
||||
|
||||
# Combine: clustered first, then shuffled non-clustered
|
||||
@@ -402,7 +407,8 @@ def render_newsletter_html(articles, subscriber_categories=None, tracking_enable
|
||||
'general': {'name': 'Top Trending', 'icon': '🔥'},
|
||||
'local': {'name': 'Local Events', 'icon': '🏛️'},
|
||||
'sports': {'name': 'Sports', 'icon': '⚽'},
|
||||
'science': {'name': 'Science & Tech', 'icon': '🔬'}
|
||||
'science': {'name': 'Science & Tech', 'icon': '🔬'},
|
||||
'business': {'name': 'Business', 'icon': '💼'}
|
||||
}
|
||||
|
||||
for category, category_articles in sorted(articles_by_category.items()):
|
||||
|
||||
Reference in New Issue
Block a user