update
This commit is contained in:
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user