From 6346e29b8f748f8cd7e313b57ad9cdf2ef6f98e3 Mon Sep 17 00:00:00 2001 From: Shane Date: Mon, 12 May 2025 16:10:15 +1000 Subject: [PATCH] update --- foodie_weekly_thread.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/foodie_weekly_thread.py b/foodie_weekly_thread.py index 60c5520..af4f5f3 100644 --- a/foodie_weekly_thread.py +++ b/foodie_weekly_thread.py @@ -308,7 +308,7 @@ def post_weekly_thread(): if username in posts_by_author: posts_by_author[username].append(post) - # Generate thread content for each author and save to file + # Generate thread content for each author thread_content = [] timestamp = datetime.now(timezone.utc).isoformat() @@ -366,20 +366,17 @@ def post_weekly_thread(): logging.error(f"Error generating thread content for {username}: {e}", exc_info=True) continue - # Save thread content to file + # Save thread content to file, overwriting any existing content if thread_content: try: - # Load existing threads, if any - existing_threads = load_json_file(WEEKLY_THREADS_FILE, default=[]) - # Append new thread content - existing_threads.append({ + # Save new thread content, overwriting the file + thread_data = { "week_start": start_date.isoformat(), "week_end": end_date.isoformat(), "timestamp": timestamp, "threads": thread_content - }) - # Save to file - save_json_file(WEEKLY_THREADS_FILE, existing_threads) + } + save_json_file(WEEKLY_THREADS_FILE, thread_data) logging.info(f"Saved thread content for {len(thread_content)} authors to {WEEKLY_THREADS_FILE}") except Exception as e: logging.error(f"Failed to save thread content to {WEEKLY_THREADS_FILE}: {e}")