New filters

dev
timofejmalinin 3 years ago
parent c580a8a9bf
commit f145787fa5

@ -14,6 +14,8 @@ def raschet(tables, filters, koefs):
conn = sqlalchemy.create_engine(settings.DB_URL, connect_args={'options': '-csearch_path=public'})
msk_ao = filters.get('msk_ao')
msk_rayon = filters.get('msk_rayon')
rate_from = filters.get('rate_from', None)
rate_to = filters.get('rate_to', None)
category = filters.get('category', [])
categories = ','.join([f"'{c}'" for c in category])
points_df = None
@ -28,6 +30,8 @@ def raschet(tables, filters, koefs):
query = f"select * from {table} where category in ({categories});" if len(categories) > 0 else f"select * from {table};"
points = pd.read_sql(query, conn)
points_df = raschet_real(points, koefs)
if rate_from is not None and rate_to is not None:
points_df = points_df[(points_df['rate'] >= rate_from) & (points_df['rate'] <= rate_to)]
if 'net' in table:
if msk_ao is not None:
@ -38,5 +42,7 @@ def raschet(tables, filters, koefs):
query = f"select * from {table};"
nets = pd.read_sql(query, conn)
nets_df = raschet_real(nets, koefs)
if rate_from is not None and rate_to is not None:
nets_df = nets_df[(nets_df['rate'] >= rate_from) & (nets_df['rate'] <= rate_to)]
return points_df, nets_df

Loading…
Cancel
Save