From 9da80d1c4a29ebf4202955834179c260efb78311 Mon Sep 17 00:00:00 2001 From: rjambrecic <32619626+rjambrecic@users.noreply.github.com> Date: Thu, 28 Nov 2024 14:21:34 +0100 Subject: [PATCH 1/3] Update packages (#168) --- pyproject.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5b3a794..069b0fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ dependencies = [ "pydantic>=2.3,<3", "fastapi>=0.110.2", "prisma==0.13.1", - "google-api-python-client==2.149.0", + "google-api-python-client==2.154.0", "asyncify==0.10.0", "pandas==2.2.3" ] @@ -56,7 +56,7 @@ dependencies = [ # public distributions server = [ - "uvicorn==0.32.0", + "uvicorn==0.32.1", ] # dev dependencies @@ -67,15 +67,15 @@ lint = [ "types-Pygments", "types-docutils", "mypy==1.13.0", - "ruff==0.6.9", + "ruff==0.8.0", "pyupgrade-directories==0.3.0", "bandit==1.7.10", - "semgrep==1.90.0", + "semgrep==1.97.0", "pytest-mypy-plugins==3.1.2", ] test-core = [ - "coverage[toml]==7.6.4", + "coverage[toml]==7.6.8", "pytest==8.3.3", "pytest-asyncio==0.24.0", ] From 3c7050892607306c9c9c050795dbe8a8ec309a5d Mon Sep 17 00:00:00 2001 From: rjambrecic <32619626+rjambrecic@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:41:08 +0100 Subject: [PATCH 2/3] Fix sheet category merge to be case insensitive (#173) --- google_sheets/app.py | 7 +++++++ google_sheets/data_processing/processing.py | 2 +- tests/app/test_app.py | 20 ++++++++------------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/google_sheets/app.py b/google_sheets/app.py index 94193a7..410b54f 100644 --- a/google_sheets/app.py +++ b/google_sheets/app.py @@ -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, diff --git a/google_sheets/data_processing/processing.py b/google_sheets/data_processing/processing.py index 362d5a9..6520deb 100644 --- a/google_sheets/data_processing/processing.py +++ b/google_sheets/data_processing/processing.py @@ -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( diff --git a/tests/app/test_app.py b/tests/app/test_app.py index 5669b38..53f09ee 100644 --- a/tests/app/test_app.py +++ b/tests/app/test_app.py @@ -358,8 +358,8 @@ class TestProcessData: ( GoogleSheetValues( values=[ - ["Fake column"], - ["fake"], + ["Fake column", "Category"], + ["fake", "Bus"], ] ), GoogleSheetValues( @@ -371,6 +371,7 @@ class TestProcessData: "Final Url From", "Final Url To", "Language Code", + "Category", ], [ "India", @@ -379,6 +380,7 @@ class TestProcessData: "https://www.example.com/from", "https://www.example.com/to", "EN", + "Bus", ], ] ), @@ -394,8 +396,6 @@ class TestProcessData: "Negative", "Language Code", "Category", - "Ad Group Category", - "Real Category", ], [ "Keyword A", @@ -404,8 +404,6 @@ class TestProcessData: "False", "EN", "Bus", - "Bus", - "Bus", ], [ "Keyword N", @@ -414,8 +412,6 @@ class TestProcessData: "True", "EN", "Bus", - "Bus", - "Bus", ], ] ), @@ -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): @@ -535,8 +533,6 @@ async def test_process_data_ads(self) -> None: "Path 1", "Path 2", "Match Type", - "Ad Group Category", - "Real Category", ], [ "EN", @@ -550,8 +546,6 @@ async def test_process_data_ads(self) -> None: "Path 1", "Path 2", "Exact", - "Bus", - "Bus", ], ] ) @@ -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( From b6c954ae97176c0e18e7f9a22bd01cb368380442 Mon Sep 17 00:00:00 2001 From: rjambrecic <32619626+rjambrecic@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:54:07 +0100 Subject: [PATCH 3/3] Update packages (#175) --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 069b0fb..bd16042 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,16 +67,16 @@ lint = [ "types-Pygments", "types-docutils", "mypy==1.13.0", - "ruff==0.8.0", + "ruff==0.8.1", "pyupgrade-directories==0.3.0", - "bandit==1.7.10", + "bandit==1.8.0", "semgrep==1.97.0", "pytest-mypy-plugins==3.1.2", ] test-core = [ "coverage[toml]==7.6.8", - "pytest==8.3.3", + "pytest==8.3.4", "pytest-asyncio==0.24.0", ]