mvp table with alc predict and ready date
All checks were successful
Build and Push Image / Build and push image (push) Has been skipped
All checks were successful
Build and Push Image / Build and push image (push) Has been skipped
This commit is contained in:
parent
436836d4ac
commit
dc7fa20e92
@ -9,6 +9,9 @@ class BeerCharts():
|
||||
def __init__(self):
|
||||
self.db = db_conn()
|
||||
|
||||
def bar_chart(self, items, data):
|
||||
return 0
|
||||
|
||||
|
||||
def line_chart(self, title, field, limit):
|
||||
data = self.db.beer_db
|
||||
|
@ -24,24 +24,29 @@ class TableBuilder():
|
||||
df_dict["final_reading"].append(record["final_reading"])
|
||||
df = pd.DataFrame(data=df_dict)
|
||||
sql = f"""
|
||||
SELECT x.beer_run_id as "Beer Run",
|
||||
max(sg) as "Max",
|
||||
min(sg) as "Min"
|
||||
SELECT x.beer_run_id as beer_run_id,
|
||||
max(sg) as max,
|
||||
min(sg) as min,
|
||||
y.date as final_reading_date
|
||||
FROM df x
|
||||
JOIN
|
||||
( SELECT DISTINCT beer_run_id
|
||||
( SELECT DISTINCT beer_run_id, date
|
||||
FROM df
|
||||
WHERE final_reading = 'True'
|
||||
) y ON x.beer_run_id = y.beer_run_id
|
||||
GROUP BY x.beer_run_id
|
||||
GROUP BY x.beer_run_id, y.date
|
||||
ORDER BY x.beer_run_id desc
|
||||
LIMIT {limit}
|
||||
"""
|
||||
df_sum = duckdb.sql(sql).df()
|
||||
sql = f"""
|
||||
SELECT *,
|
||||
ROUND(((CAST (max AS INTEGER) - CAST(min AS INTEGER)) / 7.36) + 0.5, 2) AS "Alcohol Prediction"
|
||||
FROM df_sum
|
||||
SELECT x.beer_run_id as "Beer Run",
|
||||
x.max as "Max",
|
||||
x.min as "Min",
|
||||
ROUND(((CAST (max AS INTEGER) - CAST(min AS INTEGER)) / 7.36) + 0.5, 2) AS "Alcohol Prediction",
|
||||
cast(final_reading_date as DATE) + INTERVAL 14 DAY as "Ready Date"
|
||||
|
||||
FROM df_sum x
|
||||
"""
|
||||
df_calc = duckdb.sql(sql).df()
|
||||
return df_calc
|
||||
|
Loading…
x
Reference in New Issue
Block a user