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

2737 street view gps #2748

Merged
merged 9 commits into from
Jan 19, 2025
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: 2 additions & 2 deletions anyway/infographics_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ def get_infographics_data_for_location(request_params: RequestParams) -> Dict:
elif WIDGETS not in output:
logging.error(f"get_infographics_data: 'widgets' key missing from output:{output}")
else:
non_empty = list(filter(lambda x: x[DATA][ITEMS], output[WIDGETS]))
output[WIDGETS] = update_cache_results(request_params, non_empty)
updated_output = update_cache_results(request_params, output[WIDGETS])
output[WIDGETS] = list(filter(lambda x: x[DATA][ITEMS], updated_output))
return output


Expand Down
11 changes: 9 additions & 2 deletions anyway/widgets/road_segment_widgets/street_view_widget.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging
from anyway.request_params import RequestParams
from anyway.widgets.widget import register
from anyway.widgets.road_segment_widgets.road_segment_widget import RoadSegmentWidget
from typing import Dict
from typing import Dict, Optional
from flask_babel import _


Expand All @@ -23,8 +24,14 @@ def generate_items(self) -> None:
def is_included(self):
return self.request_params.gps and self.request_params.gps.get("lon") and self.request_params.gps.get("lat")


@staticmethod
def localize_items(request_params: RequestParams, items: Dict) -> Dict:
items["data"]["text"] = {"title": _("Street view widget")}
return items

@classmethod
def update_result(cls, request_params: RequestParams, cached_items: Dict) -> Optional[Dict]:
try:
return cls.generate_widget_data(request_params)
except Exception as e:
logging.debug(f"Encountered error when generating items for widget class {cls} : {e}")
Loading