diff --git a/python_fb_page_insights_client/fb_page_insight.py b/python_fb_page_insights_client/fb_page_insight.py index 17cf5b7..b1cbe2b 100644 --- a/python_fb_page_insights_client/fb_page_insight.py +++ b/python_fb_page_insights_client/fb_page_insight.py @@ -94,7 +94,7 @@ class PostMetric(Enum): post_engaged_fan = auto() # post_clicks post_clicks_unique = auto() - # post_clicks_by_type + # x post_clicks_by_type # "value": { # "other clicks": 147, # "photo view": 9, @@ -116,7 +116,7 @@ class PostMetric(Enum): post_impressions_viral_unique = auto() post_impressions_nonviral = auto() post_impressions_nonviral_unique = auto() - # "value": { + # x "value": { # PageStoryValue # "other": 6502 # } post_impressions_by_story_type = auto() # by type @@ -125,7 +125,7 @@ class PostMetric(Enum): # Page Post Reactions post_reactions_sorry_total = auto() post_reactions_anger_total = auto() - # "value": { + # x "value": { # "like": 69, # "love": 1 # } @@ -133,7 +133,7 @@ class PostMetric(Enum): # Stories post_activity_unique = auto() - # "value": { + # x "value": { # PostActivityValue # "share": 13, # "like": 58, # "comment": 6 @@ -178,14 +178,22 @@ class PostMetric(Enum): post_video_view_time = auto() post_video_view_time_organic = auto() # "data": [] ???? + # TODO 1: like page_impressions_by_age_gender_unique? post_video_view_time_by_age_bucket_and_gender = auto() - # "value": {} + # "values": [ + # { + # "value": {} // usually it is just a simple "value": 0 + # } + # ], + # TODO: find a sample !!!!??? post_video_view_time_by_region_id = auto() # "value": {} + # TODO: like page_impressions_viral_frequency_distribution? post_video_views_by_distribution_type = auto() - # "value": {} + # "value": {}, post_video_view_time_by_distribution_type = auto() # "value": {} + # should like page_impressions_by_country_unique post_video_view_time_by_country_id = auto() # Video Ad Breaks @@ -349,7 +357,7 @@ class PageMetric(Enum): page_impressions_viral_unique = auto() page_impressions_nonviral = auto() page_impressions_nonviral_unique = auto() - # "page post": 422, + # x "page post": 422, # "other": 10 page_impressions_by_story_type = auto() page_impressions_by_story_type_unique = auto() @@ -385,7 +393,7 @@ class PageMetric(Enum): # "3": 1, # "5": 1, # "6-10": 4 - # }, + # }, page_impressions_viral_frequency_distribution = auto() # Page Posts @@ -486,7 +494,7 @@ class PageMetric(Enum): # "none": 13 page_views_by_referers_logged_in_unique = auto() - # Stories: + # x Stories: # "fan": 56, # "other": 262, # "mention": 4, @@ -498,9 +506,17 @@ class PageMetric(Enum): page_content_activity_by_country_unique = auto() page_content_activity_by_locale_unique = auto() page_content_activity = auto() + # x PageStoryValue # "fan": 4, # "page post": 2, # "other": 29 + # { + # "value": { + # "other": 12, + # "fan": 10 + # }, + # "end_time": "2021-10-25T07:00:00+0000" + # }, page_content_activity_by_action_type = auto() # by type # Video Ad Breaks @@ -541,7 +557,29 @@ class PostClickValue(BaseModel): other_clicks: int = Field(None, alias="other clicks") -class ByTypeValue(PostActivityValue, PostClickValue): +class PageStoryValue(BaseModel): + # use by Page & Page, too + checkin: int = None + coupon: int = None + event: int = None + fan: int = None + mention: int = None + page_post: int = Field(None, alias="page post") + question: int = None + user_post: int = Field(None, alias="user post") + other: int = None + + +class PostReactionType(BaseModel): + sorry: Optional[int] + anger: Optional[int] + like: Optional[int] + love: Optional[int] + wow: Optional[int] + haha: Optional[int] + + +class ByTypeValue(PostActivityValue, PostClickValue, PageStoryValue, PostReactionType): """since pydantic union has some bug, so combine them (intersection)""" # TODO: add more ByTypeValue, e.g. page_positive_feedback_by_type @@ -1271,7 +1309,8 @@ def _organize_to_web_page_data_shape( """currently it only support one period, it querying with on specific period in low level api, will return multiple periods""" - insight_dict: Dict[int:PageDefaultWebInsight] = {} + # TODO: test it, previously it is using [int, PageDefaultWebInsight] + insight_dict: Dict[int, PageDefaultWebInsight] = {} for page_insight_data in page_data: key = page_insight_data.name