Skip to content

Commit

Permalink
Fix sheet category merge to be case insensitive (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjambrecic authored Dec 9, 2024
1 parent 9da80d1 commit 3c70508
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
7 changes: 7 additions & 0 deletions google_sheets/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,13 @@ async def process_data(
status_code=status.HTTP_400_BAD_REQUEST, detail=validation_error_msg
)

template_df["Category"] = template_df["Category"].str.lower()
new_campaign_df["Category"] = new_campaign_df["Category"].str.lower()
for col in ["Ad Group Category", "Real Category"]:
merged_campaigns_ad_groups_df[col] = merged_campaigns_ad_groups_df[
col
].str.lower()

processed_df = process_data_f(
merged_campaigns_ad_groups_df,
template_df,
Expand Down
2 changes: 1 addition & 1 deletion google_sheets/data_processing/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def _replace_headline_values(new_row: pd.Series, station: Dict[str, Any]) -> pd.
return new_row


USE_ORIGINAL_STATION_FROM = ["Transfer", "Taxi"]
USE_ORIGINAL_STATION_FROM = ["transfer", "taxi"]


def _process_row(
Expand Down
20 changes: 8 additions & 12 deletions tests/app/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ class TestProcessData:
(
GoogleSheetValues(
values=[
["Fake column"],
["fake"],
["Fake column", "Category"],
["fake", "Bus"],
]
),
GoogleSheetValues(
Expand All @@ -371,6 +371,7 @@ class TestProcessData:
"Final Url From",
"Final Url To",
"Language Code",
"Category",
],
[
"India",
Expand All @@ -379,6 +380,7 @@ class TestProcessData:
"https://www.example.com/from",
"https://www.example.com/to",
"EN",
"Bus",
],
]
),
Expand All @@ -394,8 +396,6 @@ class TestProcessData:
"Negative",
"Language Code",
"Category",
"Ad Group Category",
"Real Category",
],
[
"Keyword A",
Expand All @@ -404,8 +404,6 @@ class TestProcessData:
"False",
"EN",
"Bus",
"Bus",
"Bus",
],
[
"Keyword N",
Expand All @@ -414,8 +412,6 @@ class TestProcessData:
"True",
"EN",
"Bus",
"Bus",
"Bus",
],
]
),
Expand Down Expand Up @@ -498,6 +494,8 @@ async def test_process_data_keywords(
"Ad Group Name": ["{INSERT_STATION_FROM} - {INSERT_STATION_TO}"],
"Match Type": ["Exact"],
"Target Category": ["True"],
"Ad Group Category": ["Bus"],
"Real Category": ["Bus"],
}
)
if isinstance(detail, GoogleSheetValues):
Expand Down Expand Up @@ -535,8 +533,6 @@ async def test_process_data_ads(self) -> None:
"Path 1",
"Path 2",
"Match Type",
"Ad Group Category",
"Real Category",
],
[
"EN",
Expand All @@ -550,8 +546,6 @@ async def test_process_data_ads(self) -> None:
"Path 1",
"Path 2",
"Exact",
"Bus",
"Bus",
],
]
)
Expand Down Expand Up @@ -588,6 +582,8 @@ async def test_process_data_ads(self) -> None:
"Ad Group Name": ["{INSERT_STATION_FROM} - {INSERT_STATION_TO}"],
"Match Type": ["Exact"],
"Target Category": ["False"],
"Ad Group Category": ["bus"],
"Real Category": ["bus"],
}
)
result = await process_data(
Expand Down

0 comments on commit 3c70508

Please sign in to comment.