From 7451cf9ddd9a5961560c53ba28549bd59d91c506 Mon Sep 17 00:00:00 2001 From: "WQY\\qiong" Date: Fri, 24 Mar 2023 21:17:22 +0800 Subject: [PATCH] Need insert since it requires update later --- api/s24_coordinates.py | 3 ++- api/s2_junctions.py | 2 -- api/s3_reservoirs.py | 2 -- api/s4_tanks.py | 2 -- 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/api/s24_coordinates.py b/api/s24_coordinates.py index ba5dd73..6c54245 100644 --- a/api/s24_coordinates.py +++ b/api/s24_coordinates.py @@ -9,7 +9,8 @@ def _to_client_point(coord: str) -> dict[str, float]: def get_node_coord(name: str, id: str) -> dict[str, float]: row = try_read(name, f"select * from coordinates where node = '{id}'") if row == None: - return {} + write(name, f"insert into coordinates (node, coord) values ('{id}', '(0.0,0.0)');") + return {'x': 0.0, 'y': 0.0} return _to_client_point(row['coord']) diff --git a/api/s2_junctions.py b/api/s2_junctions.py index 515dac4..28aadd0 100644 --- a/api/s2_junctions.py +++ b/api/s2_junctions.py @@ -16,8 +16,6 @@ def get_junction(name: str, id: str) -> dict[str, Any]: if j == None: return {} xy = get_node_coord(name, id) - if xy == {}: - xy = {'x': 0.0, 'y': 0.0} d = {} d['id'] = str(j['id']) d['x'] = float(xy['x']) diff --git a/api/s3_reservoirs.py b/api/s3_reservoirs.py index 23a2d9c..d3a3d7f 100644 --- a/api/s3_reservoirs.py +++ b/api/s3_reservoirs.py @@ -17,8 +17,6 @@ def get_reservoir(name: str, id: str) -> dict[str, Any]: if r == None: return {} xy = get_node_coord(name, id) - if xy == {}: - xy = {'x': 0.0, 'y': 0.0} d = {} d['id'] = str(r['id']) d['x'] = float(xy['x']) diff --git a/api/s4_tanks.py b/api/s4_tanks.py index 09a8f61..45341fe 100644 --- a/api/s4_tanks.py +++ b/api/s4_tanks.py @@ -27,8 +27,6 @@ def get_tank(name: str, id: str) -> dict[str, Any]: if t == None: return {} xy = get_node_coord(name, id) - if xy == {}: - xy = {'x': 0.0, 'y': 0.0} d = {} d['id'] = str(t['id']) d['x'] = float(xy['x'])