Skip to content

Commit cd490b7

Browse files
committed
Update remaining API calls after oebb change
1 parent aa8ecb9 commit cd490b7

3 files changed

Lines changed: 266 additions & 46 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ repos:
33
rev: 24.8.0
44
hooks:
55
- id: black
6-
language_version: python3.12
6+
language_version: python3.13

app/util.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from app.db import db
1111
from app.models import Price, AuthToken
1212
from util.oebb import (
13-
get_station_id,
13+
get_station_details,
1414
get_travel_action_id,
1515
get_connection_ids,
1616
get_price_for_connection,
@@ -82,8 +82,8 @@ def get_price_generator(
8282
current_step += 1
8383
current_message = _("Processing origin")
8484
yield render(current_message, current_step, total_steps)
85-
origin_id = get_station_id(origin, access_token=access_token)
86-
if not origin_id:
85+
origin_details = get_station_details(origin, access_token=access_token)
86+
if not origin_details or not origin_details.get("number"):
8787
logger.warning("Could not process origin.")
8888
current_message = _("Failed to process origin")
8989
yield render(current_message)
@@ -92,8 +92,8 @@ def get_price_generator(
9292
current_step += 1
9393
current_message = _("Processing destination")
9494
yield render(current_message, current_step, total_steps)
95-
destination_id = get_station_id(destination, access_token=access_token)
96-
if not destination_id:
95+
destination_details = get_station_details(destination, access_token=access_token)
96+
if not destination_details or not destination_details.get("number"):
9797
logger.warning("Could not process destination.")
9898
current_message = _("Failed to process destination")
9999
yield render(current_message)
@@ -103,7 +103,10 @@ def get_price_generator(
103103
current_message = _("Processing travel action")
104104
yield render(current_message, current_step, total_steps)
105105
travel_action_id = get_travel_action_id(
106-
origin_id, destination_id, date=date, access_token=access_token
106+
origin_details["number"],
107+
destination_details["number"],
108+
date=date,
109+
access_token=access_token,
107110
)
108111
if not travel_action_id:
109112
logger.warning("Could not process travel action.")
@@ -116,6 +119,8 @@ def get_price_generator(
116119
yield render(current_message, current_step, total_steps)
117120
connection_ids = get_connection_ids(
118121
travel_action_id,
122+
origin_details,
123+
destination_details,
119124
date=date,
120125
get_only_first=False,
121126
access_token=access_token,

0 commit comments

Comments
 (0)