From 0cdc9a58049e276aea2189241cd10fc68f57f616 Mon Sep 17 00:00:00 2001 From: ziv Date: Sat, 16 Dec 2023 03:53:49 +0200 Subject: [PATCH] testing --- .../accident_count_by_severity_widget.py | 4 ++-- anyway/widgets/segment_junctions.py | 14 +++++++------- anyway/widgets/widget_utils.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/anyway/widgets/all_locations_widgets/accident_count_by_severity_widget.py b/anyway/widgets/all_locations_widgets/accident_count_by_severity_widget.py index 546ad583..0cc6b95f 100644 --- a/anyway/widgets/all_locations_widgets/accident_count_by_severity_widget.py +++ b/anyway/widgets/all_locations_widgets/accident_count_by_severity_widget.py @@ -98,7 +98,7 @@ def get_transcription(request_params: RequestParams, items: Dict): segment_name=_(request_params.location_info.get('road_segment_name')), ) else: - raise Exception(f"cannot convert to hebrew for resolution : {request_params.resolution.get('resolution')}") + raise Exception(f"cannot convert to hebrew for resolution : {request_params.resolution.value}") text += "{between_years_keyword} {start_year} - {end_year}, {separator_keyword} {incidents_num} {incident_keyword}, {out_of_them_keywoard} ".format( between_years_keyword=_("between the years"), start_year=request_params.start_time.year, @@ -170,4 +170,4 @@ def localize_items(request_params: RequestParams, items: Dict) -> Dict: _("out of them") _("accidents") _(" and ") -_("in the selected time") \ No newline at end of file +_("in the selected time") diff --git a/anyway/widgets/segment_junctions.py b/anyway/widgets/segment_junctions.py index ca4ca874..b10cfce6 100644 --- a/anyway/widgets/segment_junctions.py +++ b/anyway/widgets/segment_junctions.py @@ -37,12 +37,12 @@ def __calc_fill_segment_junctions(): rkj[t.road][t.km] = t.non_urban_intersection tmp: List[RoadSegments] = db.session.query(RoadSegments).all() segments = {t.segment_id: t for t in tmp} - for k, v in segments.items(): - if v.road not in rkj: - logging.warning(f"No junctions in road {v.road}.") + for seg_id, seg in segments.items(): + if seg.road not in rkj: + logging.warning(f"No junctions in road {seg.road}.") continue - # logger.debug(f"seg:{k},road:{v.road}:juncs:{rkj[v.road]}.") - junctions = [rkj[v.road][km] for km in rkj[v.road].keys() if v.from_km <= km <= v.to_km] - # logger.debug(f"segment junctions:{junctions}") - res[k] = junctions + junctions = [ + rkj[seg.road][km] for km in rkj[seg.road].keys() if seg.from_km <= km <= seg.to_km + ] + res[seg_id] = junctions return res diff --git a/anyway/widgets/widget_utils.py b/anyway/widgets/widget_utils.py index 9777cd1c..8809796e 100644 --- a/anyway/widgets/widget_utils.py +++ b/anyway/widgets/widget_utils.py @@ -31,7 +31,7 @@ def get_query(table_obj, filters, start_time, end_time): return query location_fields, other_fields = split_location_fields_and_others(filters) if other_fields: - query = query.filter(get_expression_for_fields(filters, table_obj, and_)) + query = query.filter(get_expression_for_fields(other_fields, table_obj, and_)) query = query.filter( get_expression_for_road_segment_location_fields(location_fields, table_obj) )