Spaces:
Running
Running
Update linkedin_follower_stats.py
Browse files- linkedin_follower_stats.py +10 -8
linkedin_follower_stats.py
CHANGED
@@ -305,13 +305,16 @@ def fetch_follower_demographics(session, org_urn, functions_map, seniorities_map
|
|
305 |
return current_type_entries
|
306 |
|
307 |
for item in raw_items_list:
|
|
|
308 |
category_name_val = "Unknown"
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
|
|
|
|
315 |
|
316 |
counts = item.get("followerCounts", {})
|
317 |
organic_count = counts.get("organicFollowerCount", 0)
|
@@ -336,8 +339,7 @@ def fetch_follower_demographics(session, org_urn, functions_map, seniorities_map
|
|
336 |
{"items_key": "followerCountsBySeniority", "type_name": "follower_seniority", "id_map": seniorities_map, "id_field": "seniority", "top_n": 10},
|
337 |
{"items_key": "followerCountsByFunction", "type_name": "follower_function", "id_map": functions_map, "id_field": "function", "top_n": 10},
|
338 |
{"items_key": "followerCountsByIndustry", "type_name": "follower_industry", "id_map": live_industries_map, "id_field": "industry", "top_n": 10},
|
339 |
-
{"items_key": "followerCountsByGeoCountry", "type_name": "follower_geo", "id_map": live_geo_map, "id_field": "geo", "top_n": 10}
|
340 |
-
{"items_key": "followerCountsByAssociationType", "type_name": "follower_association", "id_map": {}, "id_field": "associationType", "top_n": None}
|
341 |
]
|
342 |
|
343 |
for config in demographic_configs:
|
|
|
305 |
return current_type_entries
|
306 |
|
307 |
for item in raw_items_list:
|
308 |
+
# Default category name
|
309 |
category_name_val = "Unknown"
|
310 |
+
|
311 |
+
# For all types (since follower_association is removed), we parse URN and map to name
|
312 |
+
urn_val = item.get(id_field_name_in_item)
|
313 |
+
entity_id = _parse_urn_to_id(urn_val)
|
314 |
+
|
315 |
+
# Use a more descriptive unknown if ID mapping fails
|
316 |
+
unknown_label_suffix = type_name.split('_')[-1].capitalize() if '_' in type_name else type_name.capitalize()
|
317 |
+
category_name_val = id_map.get(str(entity_id), f"Unknown {unknown_label_suffix} (ID: {entity_id if entity_id else urn_val})")
|
318 |
|
319 |
counts = item.get("followerCounts", {})
|
320 |
organic_count = counts.get("organicFollowerCount", 0)
|
|
|
339 |
{"items_key": "followerCountsBySeniority", "type_name": "follower_seniority", "id_map": seniorities_map, "id_field": "seniority", "top_n": 10},
|
340 |
{"items_key": "followerCountsByFunction", "type_name": "follower_function", "id_map": functions_map, "id_field": "function", "top_n": 10},
|
341 |
{"items_key": "followerCountsByIndustry", "type_name": "follower_industry", "id_map": live_industries_map, "id_field": "industry", "top_n": 10},
|
342 |
+
{"items_key": "followerCountsByGeoCountry", "type_name": "follower_geo", "id_map": live_geo_map, "id_field": "geo", "top_n": 10}
|
|
|
343 |
]
|
344 |
|
345 |
for config in demographic_configs:
|