Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ticket price to headlines #107

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions google_sheets/data_processing/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def validate_input_data(
INSERT_CRITERION_TYPE = "{INSERT_CRITERION_TYPE}"
INSERT_LANGUAGE_CODE = "{INSERT_LANGUAGE_CODE}"
INSERT_CATEGORY = "{INSERT_CATEGORY}"
INSERT_TICKET_PRICE = "{INSERT_TICKET_PRICE}"


def _update_campaign_name(
Expand Down Expand Up @@ -204,6 +205,9 @@ def _process_row(
new_row = new_row.str.replace(INSERT_STATION_TO, station["Station To"])
new_row = new_row.str.replace(INSERT_CRITERION_TYPE, new_row["Match Type"])
new_row = new_row.str.replace(INSERT_CATEGORY, new_campaign_row["Category"])
new_row = new_row.str.replace(
INSERT_TICKET_PRICE, new_campaign_row["Ticket Price"]
)

if target_resource == "ad":
new_row["Final URL"] = station["Final Url"]
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies = [
"pydantic>=2.3,<3",
"fastapi>=0.110.2",
"prisma==0.13.1",
"google-api-python-client==2.143.0",
"google-api-python-client==2.144.0",
"asyncify==0.10.0",
"pandas==2.2.2"
]
Expand All @@ -67,10 +67,10 @@ lint = [
"types-Pygments",
"types-docutils",
"mypy==1.11.2",
"ruff==0.6.3",
"ruff==0.6.4",
"pyupgrade-directories==0.3.0",
"bandit==1.7.9",
"semgrep==1.85.0",
"semgrep==1.86.0",
"pytest-mypy-plugins==3.1.2",
]

Expand Down
10 changes: 7 additions & 3 deletions tests/app/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ class TestProcessData:
"Final Url To",
"Language Code",
"Category",
"Ticket Price",
],
[
"India",
Expand All @@ -418,6 +419,7 @@ class TestProcessData:
"https://www.example.com/to",
"EN",
"Bus",
"10.5",
],
]
),
Expand Down Expand Up @@ -517,7 +519,7 @@ async def test_process_data_ads(self) -> None:
"Bus",
"https://www.example.com/from",
"H" * 31,
"Headline 2",
"Headline 2 {INSERT_TICKET_PRICE}",
"Headline 3",
"Description Line 1",
"Description Line 2",
Expand All @@ -536,6 +538,7 @@ async def test_process_data_ads(self) -> None:
"Final Url To",
"Language Code",
"Category",
"Ticket Price",
],
[
"India",
Expand All @@ -545,6 +548,7 @@ async def test_process_data_ads(self) -> None:
"https://www.example.com/to",
"EN",
"Bus",
"10.5",
],
]
)
Expand Down Expand Up @@ -588,7 +592,7 @@ async def test_process_data_ads(self) -> None:
"Exact",
"https://www.example.com/from",
"HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH",
"Headline 2",
"Headline 2 10.5",
"Headline 3",
"Description Line 1",
"Description Line 2",
Expand All @@ -602,7 +606,7 @@ async def test_process_data_ads(self) -> None:
"Exact",
"https://www.example.com/to",
"HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH",
"Headline 2",
"Headline 2 10.5",
"Headline 3",
"Description Line 1",
"Description Line 2",
Expand Down
5 changes: 5 additions & 0 deletions tests/data_processing/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def test_process_row(
"Station To": "B",
"Language Code": "EN",
"Category": category,
"Ticket Price": "100",
}
)
final_df = pd.DataFrame(columns=template_row.index)
Expand Down Expand Up @@ -177,6 +178,7 @@ def test_process_row(
"Station To": ["C", "D"],
"Language Code": ["EN", "EN"],
"Category": ["Bus", "Bus"],
"Ticket Price": ["100", "200"],
}
),
pd.DataFrame(
Expand Down Expand Up @@ -256,6 +258,7 @@ def test_process_row(
"Station To": ["C", "D"],
"Language Code": ["EN", "EN"],
"Category": ["Bus", "Bus"],
"Ticket Price": ["100", "200"],
}
),
pd.DataFrame(
Expand Down Expand Up @@ -339,6 +342,7 @@ def test_process_row(
"Station To": ["C", "D"],
"Language Code": ["EN", "DE"],
"Category": ["Bus", "Bus"],
"Ticket Price": ["100", "200"],
}
),
pd.DataFrame(
Expand Down Expand Up @@ -396,6 +400,7 @@ def test_process_row(
"Station To": ["C", "D"],
"Language Code": ["EN", "DE"],
"Category": ["Bus", "Bus"],
"Ticket Price": ["100", "200"],
}
),
pd.DataFrame(
Expand Down
Loading