diff --git a/gdrive/export_api.py b/gdrive/export_api.py index b67472a..68b84c1 100644 --- a/gdrive/export_api.py +++ b/gdrive/export_api.py @@ -173,7 +173,6 @@ async def find(find: FindModel): # ------------------------------- Archive API -------------------------------------- class InteractionModel(BaseModel): interactionId: str - driveId: str @router.post("/export/interaction-files") diff --git a/gdrive/idva/flow_analytics.py b/gdrive/idva/flow_analytics.py index 55ae826..11a66be 100644 --- a/gdrive/idva/flow_analytics.py +++ b/gdrive/idva/flow_analytics.py @@ -76,8 +76,10 @@ def preprocess_report(df: pd.DataFrame) -> pd.DataFrame: "twitter", "linked.com", "lnkd.in", + "pllpl", + "ffg", ] - tracked_mediums = ["fb", "cl", "rd", "tx", "ln"] + tracked_mediums = ["fb", "cl", "rd", "tx", "ln", "pllpl", "ffg"] for event in tracked_events: tracked_df = df[df[0] == event] @@ -134,6 +136,8 @@ def create_pivot_tables(df: pd.DataFrame, names_to_id: dict, sheets_id: str): twitter_x_pivot(sheets_id, names_to_id, col_dict) linkedin_pivot(sheets_id, names_to_id, col_dict) linked_pivot(sheets_id, names_to_id, col_dict) + pllpl_pivot(sheets_id, names_to_id, col_dict) + ffg_pivot(sheets_id, names_to_id, col_dict) sheets_client.add_pivot_tables( sheets_id, names_to_id[SheetsEnum.GSA.value], idva.clicks(col_dict) @@ -425,6 +429,34 @@ def linked_pivot(sheets_id, names_to_id, col_dict): ) +def pllpl_pivot(sheets_id, names_to_id, col_dict): + sheets_client.update_cell_value( + sheets_id, SheetsEnum.REKREWT.value, "A23", "PLLPL" + ) # Pivot table Label + + sheets_client.add_pivot_tables( + sheets_id, + names_to_id[SheetsEnum.REKREWT.value], + idva.pllpl(col_dict), + row_idx=23, + col_idx=0, + ) + + +def ffg_pivot(sheets_id, names_to_id, col_dict): + sheets_client.update_cell_value( + sheets_id, SheetsEnum.REKREWT.value, "A35", "FFG" + ) # Pivot table Label + + sheets_client.add_pivot_tables( + sheets_id, + names_to_id[SheetsEnum.REKREWT.value], + idva.ffg(col_dict), + row_idx=35, + col_idx=0, + ) + + def generate_filename(date: datetime, end_date: datetime = None): """ Return filename for the new spreadsheet to be saved as diff --git a/gdrive/idva/pivot_director.py b/gdrive/idva/pivot_director.py index 9faa80f..9146d8b 100644 --- a/gdrive/idva/pivot_director.py +++ b/gdrive/idva/pivot_director.py @@ -320,3 +320,79 @@ def linked(self, col_dict: dict) -> dict: ) return builder.render() + + def pllpl(self, col_dict: dict) -> dict: + builder = PivotTableBuilder(0, col_dict) + builder.add_row("eventName", SortOrderEnum.ASCENDING, show_totals=False) + builder.add_row("firstUserMedium", SortOrderEnum.ASCENDING) + builder.add_row("firstUserSource", SortOrderEnum.ASCENDING) + builder.add_row( + "firstUserCampaignName", SortOrderEnum.ASCENDING, show_totals=False + ) + + builder.add_value("eventCount", SummarizeFunctionEnum.SUM) + + # =OR(regexmatch(eventName,"session_start"),regexmatch(eventName,"first_visit")) + sessions = FormulaBuilder( + FormulaEnum.OR, + [ + FormulaBuilder( + FormulaEnum.REGEX_MATCH, + ["eventName", StringLiteral("session_start")], + ), + FormulaBuilder( + FormulaEnum.REGEX_MATCH, ["eventName", StringLiteral("first_visit")] + ), + ], + ) + + builder.add_filter( + "firstUserMedium", + FilterTypeEnum.TEXT_CONTAINS, + values=[UserEnteredValue("pllpl")], + ) + builder.add_filter( + "eventName", + FilterTypeEnum.CUSTOM, + values=[UserEnteredValue(sessions.render())], + ) + + return builder.render() + + def ffg(self, col_dict: dict) -> dict: + builder = PivotTableBuilder(0, col_dict) + builder.add_row("eventName", SortOrderEnum.ASCENDING, show_totals=False) + builder.add_row("firstUserMedium", SortOrderEnum.ASCENDING) + builder.add_row("firstUserSource", SortOrderEnum.ASCENDING) + builder.add_row( + "firstUserCampaignName", SortOrderEnum.ASCENDING, show_totals=False + ) + + builder.add_value("eventCount", SummarizeFunctionEnum.SUM) + + # =OR(regexmatch(eventName,"session_start"),regexmatch(eventName,"first_visit")) + sessions = FormulaBuilder( + FormulaEnum.OR, + [ + FormulaBuilder( + FormulaEnum.REGEX_MATCH, + ["eventName", StringLiteral("session_start")], + ), + FormulaBuilder( + FormulaEnum.REGEX_MATCH, ["eventName", StringLiteral("first_visit")] + ), + ], + ) + + builder.add_filter( + "firstUserMedium", + FilterTypeEnum.TEXT_CONTAINS, + values=[UserEnteredValue("ffg")], + ) + builder.add_filter( + "eventName", + FilterTypeEnum.CUSTOM, + values=[UserEnteredValue(sessions.render())], + ) + + return builder.render()