update
This commit is contained in:
@@ -308,7 +308,7 @@ def post_weekly_thread():
|
|||||||
if username in posts_by_author:
|
if username in posts_by_author:
|
||||||
posts_by_author[username].append(post)
|
posts_by_author[username].append(post)
|
||||||
|
|
||||||
# Generate thread content for each author and save to file
|
# Generate thread content for each author
|
||||||
thread_content = []
|
thread_content = []
|
||||||
timestamp = datetime.now(timezone.utc).isoformat()
|
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)
|
logging.error(f"Error generating thread content for {username}: {e}", exc_info=True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Save thread content to file
|
# Save thread content to file, overwriting any existing content
|
||||||
if thread_content:
|
if thread_content:
|
||||||
try:
|
try:
|
||||||
# Load existing threads, if any
|
# Save new thread content, overwriting the file
|
||||||
existing_threads = load_json_file(WEEKLY_THREADS_FILE, default=[])
|
thread_data = {
|
||||||
# Append new thread content
|
|
||||||
existing_threads.append({
|
|
||||||
"week_start": start_date.isoformat(),
|
"week_start": start_date.isoformat(),
|
||||||
"week_end": end_date.isoformat(),
|
"week_end": end_date.isoformat(),
|
||||||
"timestamp": timestamp,
|
"timestamp": timestamp,
|
||||||
"threads": thread_content
|
"threads": thread_content
|
||||||
})
|
}
|
||||||
# Save to file
|
save_json_file(WEEKLY_THREADS_FILE, thread_data)
|
||||||
save_json_file(WEEKLY_THREADS_FILE, existing_threads)
|
|
||||||
logging.info(f"Saved thread content for {len(thread_content)} authors to {WEEKLY_THREADS_FILE}")
|
logging.info(f"Saved thread content for {len(thread_content)} authors to {WEEKLY_THREADS_FILE}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Failed to save thread content to {WEEKLY_THREADS_FILE}: {e}")
|
logging.error(f"Failed to save thread content to {WEEKLY_THREADS_FILE}: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user