|
|
|
@ -8,7 +8,7 @@ def raschet_real(df, koefs):
|
|
|
|
df['rate'] = df['rate'] / koef_summ
|
|
|
|
df['rate'] = df['rate'] / koef_summ
|
|
|
|
return df
|
|
|
|
return df
|
|
|
|
|
|
|
|
|
|
|
|
def raschet(tables, filters, koefs):
|
|
|
|
def raschet(tables, filters, koefs, method):
|
|
|
|
conn = sqlalchemy.create_engine(settings.DB_URL, connect_args={'options': '-csearch_path=public'})
|
|
|
|
conn = sqlalchemy.create_engine(settings.DB_URL, connect_args={'options': '-csearch_path=public'})
|
|
|
|
msk_ao = filters.get('msk_ao')
|
|
|
|
msk_ao = filters.get('msk_ao')
|
|
|
|
msk_rayon = filters.get('msk_rayon')
|
|
|
|
msk_rayon = filters.get('msk_rayon')
|
|
|
|
@ -27,9 +27,12 @@ def raschet(tables, filters, koefs):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
query = f"select * from {table} where category in ({categories});" if len(categories) > 0 else f"select * from {table};"
|
|
|
|
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 = pd.read_sql(query, conn)
|
|
|
|
points_df = raschet_real(points, koefs)
|
|
|
|
if method == 'rate':
|
|
|
|
if rate_from is not None and rate_to is not None:
|
|
|
|
points_df = raschet_real(points, koefs)
|
|
|
|
points_df = points_df[(points_df['rate'] >= rate_from) & (points_df['rate'] <= rate_to)]
|
|
|
|
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)]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
points_df = points[(points['model'] >= rate_from) & (points['model'] <= rate_to)]
|
|
|
|
|
|
|
|
|
|
|
|
if 'net' in table:
|
|
|
|
if 'net' in table:
|
|
|
|
if msk_ao is not None:
|
|
|
|
if msk_ao is not None:
|
|
|
|
@ -39,8 +42,11 @@ def raschet(tables, filters, koefs):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
query = f"select * from {table};"
|
|
|
|
query = f"select * from {table};"
|
|
|
|
nets = pd.read_sql(query, conn)
|
|
|
|
nets = pd.read_sql(query, conn)
|
|
|
|
nets_df = raschet_real(nets, koefs)
|
|
|
|
if method == 'rate':
|
|
|
|
if rate_from is not None and rate_to is not None:
|
|
|
|
nets_df = raschet_real(nets, koefs)
|
|
|
|
nets_df = nets_df[(nets_df['rate'] >= rate_from) & (nets_df['rate'] <= rate_to)]
|
|
|
|
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)]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
nets_df = nets[(nets['model'] >= rate_from) & (nets['model'] <= rate_to)]
|
|
|
|
|
|
|
|
|
|
|
|
return points_df, nets_df
|
|
|
|
return points_df, nets_df
|
|
|
|
|