Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions scripts/apply_tag_topic_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,21 @@
if sheet.get('id', None) is None:
print("Sheet id is None")
continue

# DIAGNOSTIC LOGGING: Check for slugless topics before bulk write
import logging
logger = logging.getLogger(__name__)
for idx, topic in enumerate(topics):
if not topic.get("slug"):
logger.error(f"[SLUGLESS_TOPIC_TRACKER] apply_tag_topic_mapping.py: Sheet {sheet['id']} has topic without slug at index {idx}. Topic data: {topic}")
print(f"[SLUGLESS_TOPIC_TRACKER] apply_tag_topic_mapping.py: Sheet {sheet['id']}, topic index {idx}, data: {topic}")

updates += [{'id': sheet['id'], 'topics': topics}]

# DIAGNOSTIC LOGGING: Log bulk write operation
logger.warning(f"[SLUGLESS_TOPIC_TRACKER] apply_tag_topic_mapping.py: About to bulk write {len(updates)} sheet topic updates")
print(f"[SLUGLESS_TOPIC_TRACKER] Bulk writing {len(updates)} updates")

db.sheets.bulk_write([
UpdateOne({"id": l['id']}, {"$set": {"topics": l['topics']}}) for l in updates
])
Loading
Loading