Return all fuel prices per station (E5/E10/DIESEL) so clients switch fuel tabs without refetch
This commit is contained in:
@@ -273,6 +273,13 @@ def stations(
|
|||||||
continue
|
continue
|
||||||
s_lat = station.get("latitude", station.get("lat"))
|
s_lat = station.get("latitude", station.get("lat"))
|
||||||
s_lng = station.get("longitude", station.get("lng"))
|
s_lng = station.get("longitude", station.get("lng"))
|
||||||
|
# All known fuel grades for this station (E5/E10/DIESEL) so clients can
|
||||||
|
# switch fuel tabs without another request.
|
||||||
|
prices = {}
|
||||||
|
for grade in ("E5", "E10", "DIESEL"):
|
||||||
|
p = _fuel_price(station, grade)
|
||||||
|
if p is not None:
|
||||||
|
prices[grade] = p
|
||||||
item = {
|
item = {
|
||||||
"id": station.get("id") or station.get("station_id"),
|
"id": station.get("id") or station.get("station_id"),
|
||||||
"name": station.get("name") or station.get("station_name"),
|
"name": station.get("name") or station.get("station_name"),
|
||||||
@@ -282,6 +289,7 @@ def stations(
|
|||||||
"lat": s_lat,
|
"lat": s_lat,
|
||||||
"lng": s_lng,
|
"lng": s_lng,
|
||||||
"price": price,
|
"price": price,
|
||||||
|
"prices": prices,
|
||||||
"price_updated": station.get("price_updated") or station.get("updated_at"),
|
"price_updated": station.get("price_updated") or station.get("updated_at"),
|
||||||
}
|
}
|
||||||
if lat is not None and lng is not None and isinstance(s_lat, (int, float)) and isinstance(s_lng, (int, float)):
|
if lat is not None and lng is not None and isinstance(s_lat, (int, float)) and isinstance(s_lng, (int, float)):
|
||||||
|
|||||||
Reference in New Issue
Block a user