ihtesham0345 commited on
Commit
2680851
·
1 Parent(s): 91c8715

fix: add catch-all viral_hashtags mapping at end of cross_map_fields to catch hashtags set by platform-specific mappers

Browse files
Files changed (1) hide show
  1. services/utils.py +4 -0
services/utils.py CHANGED
@@ -309,6 +309,10 @@ def cross_map_fields(data: dict) -> dict:
309
  if keywords:
310
  data["hashtags"] = keywords
311
 
 
 
 
 
312
  # LinkedIn cross-maps
313
  if "post_drafts" in data and "content_titles" not in data:
314
  data["content_titles"] = [d.get("headline", str(d)) for d in data["post_drafts"] if isinstance(d, dict)]
 
309
  if keywords:
310
  data["hashtags"] = keywords
311
 
312
+ # Catch-all: if hashtags was set by any platform mapping above but viral_hashtags wasn't
313
+ if "hashtags" in data and ("viral_hashtags" not in data or data.get("viral_hashtags") is None):
314
+ data["viral_hashtags"] = [{"tag": h, "post_count": "N/A"} for h in data["hashtags"]]
315
+
316
  # LinkedIn cross-maps
317
  if "post_drafts" in data and "content_titles" not in data:
318
  data["content_titles"] = [d.get("headline", str(d)) for d in data["post_drafts"] if isinstance(d, dict)]