update
This commit is contained in:
@@ -166,8 +166,12 @@ def get_latest_articles_by_categories(categories=None, articles_per_category=3,
|
|||||||
# Get cluster summaries collection
|
# Get cluster summaries collection
|
||||||
cluster_summaries_collection = db['cluster_summaries']
|
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:
|
if categories is None:
|
||||||
|
# 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']
|
categories = ['general', 'local', 'sports', 'science']
|
||||||
|
|
||||||
articles = []
|
articles = []
|
||||||
@@ -329,7 +333,8 @@ def get_latest_articles_by_categories(categories=None, articles_per_category=3,
|
|||||||
|
|
||||||
# Reconstruct non-clustered list with shuffled articles
|
# Reconstruct non-clustered list with shuffled articles
|
||||||
non_clustered = []
|
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])
|
non_clustered.extend(by_category[cat])
|
||||||
|
|
||||||
# Combine: clustered first, then shuffled non-clustered
|
# 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': '🔥'},
|
'general': {'name': 'Top Trending', 'icon': '🔥'},
|
||||||
'local': {'name': 'Local Events', 'icon': '🏛️'},
|
'local': {'name': 'Local Events', 'icon': '🏛️'},
|
||||||
'sports': {'name': 'Sports', '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()):
|
for category, category_articles in sorted(articles_by_category.items()):
|
||||||
|
|||||||
Reference in New Issue
Block a user