Order demand, pattern and curve

This commit is contained in:
WQY\qiong
2022-10-29 09:11:27 +08:00
parent 89cc1acc66
commit 2f26cb58ad
6 changed files with 9 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ def get_pattern_schema(name: str) -> dict[str, dict[str, Any]]:
def get_pattern(name: str, id: str) -> dict[str, Any]: def get_pattern(name: str, id: str) -> dict[str, Any]:
pas = read_all(name, f"select * from patterns where id = '{id}'") pas = read_all(name, f"select * from patterns where id = '{id}' order by _order")
ps = [] ps = []
for r in pas: for r in pas:
ps.append(float(r['factor'])) ps.append(float(r['factor']))

View File

@@ -9,7 +9,7 @@ def get_curve_schema(name: str) -> dict[str, dict[str, Any]]:
def get_curve(name: str, id: str) -> dict[str, Any]: def get_curve(name: str, id: str) -> dict[str, Any]:
cus = read_all(name, f"select * from curves where id = '{id}'") cus = read_all(name, f"select * from curves where id = '{id}' order by _order")
cs = [] cs = []
for r in cus: for r in cus:
cs.append({ 'x': float(r['x']), 'y': float(r['y']) }) cs.append({ 'x': float(r['x']), 'y': float(r['y']) })

View File

@@ -10,7 +10,7 @@ def get_demand_schema(name: str) -> dict[str, dict[str, Any]]:
def get_demand(name: str, junction: str) -> dict[str, Any]: def get_demand(name: str, junction: str) -> dict[str, Any]:
des = read_all(name, f"select * from demands where junction = '{junction}'") des = read_all(name, f"select * from demands where junction = '{junction}' order by _order")
ds = [] ds = []
for r in des: for r in des:
d = {} d = {}

View File

@@ -2,6 +2,7 @@
create table patterns create table patterns
( (
id varchar(32) references _pattern(id) not null _order serial primary key
, id varchar(32) references _pattern(id) not null
, factor numeric not null , factor numeric not null
); );

View File

@@ -2,7 +2,8 @@
create table curves create table curves
( (
id varchar(32) references _curve(id) not null _order serial primary key
, id varchar(32) references _curve(id) not null
, x numeric not null , x numeric not null
, y numeric not null , y numeric not null
); );

View File

@@ -2,7 +2,8 @@
create table demands create table demands
( (
junction varchar(32) references junctions(id) not null _order serial primary key
, junction varchar(32) references junctions(id) not null
, demand numeric not null , demand numeric not null
, pattern varchar(32) references _pattern(id) , pattern varchar(32) references _pattern(id)
, category text , category text