Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin committed Jan 17, 2020
1 parent 7018669 commit a0e1b73
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 181 deletions.
45 changes: 24 additions & 21 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ def load():

@app.route('/save')
def save():

# Get user
user = models.User.query.filter_by(username = current_user.username)[0]

# Common to all (in db: gb_recipe_system)
recipe = request.args.get('recipe', 0, type=str)
Expand Down Expand Up @@ -344,24 +347,27 @@ def save():
exec("{} = request.args.get('{}', 0, type=str)".format(c,c))

# check if this already exists
Recipe = models.Recipe(recipe=recipe, style=style, notes=notes)
Recipe = models.Recipe(recipe=recipe, style=style, notes=notes, user_id=user.id)

if(len(models.Recipe.query.filter_by(recipe=Recipe.recipe).all()) == 0):
print("this recipe doesn't exist so we are adding it.")

db.session.add(Recipe)
db.session.commit()
# System
system_string = "System = models.Recipe_System(recipe_id=Recipe.id,"
for s in system_columns:

system_string = "System = models.Recipe_System(user_id=user.id, recipe_id=Recipe.id,"
for s in system_columns[1:]:
system_string = system_string + " {}={},".format(s,s)

system_string = system_string + ")"; exec(system_string)
system_string = system_string + ")";
exec(system_string)

# Fermentables
num_of_ingredients = 5
for i in range(0,num_of_ingredients):
fermentables_string = "Fermentables{} = models.Recipe_Fermentables(recipe_id=Recipe.id,".format(i+1)
for fermentables in fermentables_columns:
fermentables_string = "Fermentables{} = models.Recipe_Fermentables(user_id=user.id, recipe_id=Recipe.id,".format(i+1)
for fermentables in fermentables_columns[1:]:
fermentables_string = fermentables_string + " {}={}{},".format(fermentables,fermentables,i+1)
fermentables_string = fermentables_string + ")";
exec(fermentables_string)
Expand All @@ -373,8 +379,8 @@ def save():
# Hops
num_of_ingredients = 3
for i in range(0,num_of_ingredients):
hops_string = "Hops{} = models.Recipe_Hops(recipe_id=Recipe.id,".format(i+1)
for hops in hops_columns:
hops_string = "Hops{} = models.Recipe_Hops(user_id=user.id, recipe_id=Recipe.id,".format(i+1)
for hops in hops_columns[1:]:
hops_string = hops_string + " {}={}{},".format(hops,hops,i+1)
hops_string = hops_string + ")"
exec(hops_string)
Expand All @@ -383,36 +389,36 @@ def save():
# Hops3 = models.Recipe_Hops(recipe_id=Recipe.id, hop=hop3, weight_oz=weight_oz3, boil_time_min=boil_time_min3,)

# Mash
mash_string = "Mash = models.Recipe_Mash(recipe_id=Recipe.id,"
for m in mash_columns:
mash_string = "Mash = models.Recipe_Mash(user_id=user.id, recipe_id=Recipe.id,"
for m in mash_columns[1:]:
mash_string = mash_string + " {}={},".format(m,m)

mash_string = mash_string + ")"; exec(mash_string)

# Yeast
yeast_string = "Yeast = models.Recipe_Yeast(recipe_id=Recipe.id,"
for y in yeast_columns:
yeast_string = "Yeast = models.Recipe_Yeast(user_id=user.id, recipe_id=Recipe.id,"
for y in yeast_columns[1:]:
yeast_string = yeast_string + " {}={},".format(y,y)

yeast_string = yeast_string + ")"; exec(yeast_string)

# Water
water_string = "Water = models.Recipe_Water(recipe_id=Recipe.id,"
for w in water_columns:
water_string = "Water = models.Recipe_Water(user_id=user.id, recipe_id=Recipe.id,"
for w in water_columns[1:]:
water_string = water_string + " {}={},".format(w,w)

water_string = water_string + ")"; exec(water_string)

# Fermentation
fermentation_string = "Fermentation = models.Recipe_Fermentation(recipe_id=Recipe.id,"
for fermentation in fermentation_columns:
fermentation_string = "Fermentation = models.Recipe_Fermentation(user_id=user.id, recipe_id=Recipe.id,"
for fermentation in fermentation_columns[1:]:
fermentation_string = fermentation_string + " {}={},".format(fermentation,fermentation)

fermentation_string = fermentation_string + ")"; exec(fermentation_string)

# Chemistry
chemistry_string = "Chemistry = models.Recipe_Chemistry(recipe_id=Recipe.id,"
for c in chemistry_columns:
chemistry_string = "Chemistry = models.Recipe_Chemistry(user_id=user.id, recipe_id=Recipe.id,"
for c in chemistry_columns[1:]:
chemistry_string = chemistry_string + " {}={},".format(c,c)

chemistry_string = chemistry_string + ")"; exec(chemistry_string)
Expand Down Expand Up @@ -476,20 +482,17 @@ def brewculator():
summaries = [{'key': 'None','last_modified':'None'}]

if(len(objs)>1):
print("key exists")
objects = s3_client.list_objects_v2(Bucket='thegratefulbrauer', StartAfter=recipe_root)
summaries = []
for s in objects['Contents']:
if (s['Key'].find('.jpg') != -1 or s['Key'].find('.jpeg') != -1 or s['Key'].find('.JPG') != -1 or s['Key'].find('.PNG') != -1 or s['Key'].find('.png') != -1) and s['Key'].find(recipe_root) != -1:
print(s['Key'].find(recipe_root))
summaries.append(
{'key':s['Key'].replace(recipe_root,''),
'last_modified': s['LastModified']
}
)

else:
print("key doesn't exist, add this key")
my_bucket = s3_resource.Bucket('thegratefulbrauer')
my_bucket.put_object(Bucket='thegratefulbrauer', Body='', Key=recipe_root)

Expand Down
16 changes: 16 additions & 0 deletions manual_db_backup/pandas_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pandas as pd, psycopg2 as pg

psql = pd.io.sql


# BB - need to use the venv3.6

# get connected to the database
connection = pg.connect("host='ec2-23-21-229-48.compute-1.amazonaws.com' dbname=d4hvr3omam72o1 user=xjedptgsjqocwi password='25dfb7913372da245831b379d76ddb39eaf18eac98eade1b9542bc3ff0936dc4'")


dataframe = psql.read_sql_query("SELECT * FROM public.gb_recipe_master", connection)

print(dataframe)


22 changes: 11 additions & 11 deletions manual_db_backup/recipe_chemistry.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
id,recipe_id,init_Ca,init_Mg,init_Na,init_Cl,init_SO4,init_HCO3_CaCO3,actual_ph,effective_alkalinity,residual_alkalinity,ph_down_gypsum_CaSO4,ph_down_cal_chl_CaCl2,ph_down_epsom_salt_MgSO4,ph_up_slaked_lime_CaOH2,ph_up_baking_soda_NaHCO3,ph_up_chalk_CaCO3
174,250,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0
175,251,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0
181,257,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0
189,265,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0
206,282,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0
239,315,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0
245,321,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0
171,247,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0
172,248,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0
173,249,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0
id,recipe_id,init_Ca,init_Mg,init_Na,init_Cl,init_SO4,init_HCO3_CaCO3,actual_ph,effective_alkalinity,residual_alkalinity,ph_down_gypsum_CaSO4,ph_down_cal_chl_CaCl2,ph_down_epsom_salt_MgSO4,ph_up_slaked_lime_CaOH2,ph_up_baking_soda_NaHCO3,ph_up_chalk_CaCO3,user_id
174,250,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0,1
175,251,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0,1
181,257,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0,1
189,265,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0,19
206,282,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0,1
239,315,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0,1
245,321,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0,19
171,247,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0,1
172,248,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0,1
173,249,4,1,32,27,6,40,0,0,0,0,0,0,0,0,0,1
102 changes: 51 additions & 51 deletions manual_db_backup/recipe_fermentables.csv
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
id,recipe_id,ingredient,weight_lbs
714,250,Wheat Malt, White (Rahr),5.6
715,250,Pilsner, German (Saltzgitter),3.75
716,250,0 - None,0
717,250,0 - None,0
718,250,0 - None,0
719,251,2-Row Malt (Rahr),10
720,251,2-Row Brewers Malt (Briess),4
721,251,0 - None,0
722,251,0 - None,0
723,251,0 - None,0
874,282,Pilsner, German (Saltzgitter),12.5
875,282,Caramel_80 (Briess),0.75
876,282,Candi Sugar, Blonde (Soft),1
877,282,0 - None,0
878,282,0 - None,0
907,315,0 - None,0
908,315,0 - None,0
909,315,0 - None,0
910,315,0 - None,0
911,315,0 - None,0
749,257,2-Row Malt (Rahr),10
750,257,Caramel_40 (Briess),0.75
751,257,0 - None,0
752,257,0 - None,0
753,257,0 - None,0
937,321,Pale Ale Malt (Briess),9
938,321,Rye Malt (Weyermann),1
939,321,Chocolate Rye (Weyermann),0.25
940,321,Crystal, Medium (Simpsons),0.25
941,321,Special Roast (Briess),0.25
699,247,0 - None,0
700,247,0 - None,0
701,247,0 - None,0
702,247,0 - None,0
703,247,0 - None,0
704,248,0 - None,0
705,248,0 - None,0
706,248,0 - None,0
707,248,0 - None,0
708,248,0 - None,0
709,249,0 - None,0
710,249,0 - None,0
711,249,0 - None,0
712,249,0 - None,0
713,249,0 - None,0
789,265,2-Row Malt (Rahr),9
790,265,Pilsen (Franco-Belges),5
791,265,Candi Sugar, Blonde (Soft),1
792,265,CaraAroma (Weyermann),0.125
793,265,CaraAmber (Weyermann),0.125
id,recipe_id,ingredient,weight_lbs,user_id
714,250,'Wheat Malt, White (Rahr)',5.6,1
715,250,'Pilsner, German (Saltzgitter)',3.75,1
716,250,0 - None,0,1
717,250,0 - None,0,1
718,250,0 - None,0,1
719,251,2-Row Malt (Rahr),10,1
720,251,2-Row Brewers Malt (Briess),4,1
721,251,0 - None,0,1
722,251,0 - None,0,1
723,251,0 - None,0,1
874,282,'Pilsner, German (Saltzgitter)',12.5,1
875,282,Caramel_80 (Briess),0.75,1
876,282,'Candi Sugar, Blonde (Soft)',1,1
877,282,0 - None,0,1
878,282,0 - None,0,1
907,315,0 - None,0,1
908,315,0 - None,0,1
909,315,0 - None,0,1
910,315,0 - None,0,1
911,315,0 - None,0,1
749,257,2-Row Malt (Rahr),10,1
750,257,Caramel_40 (Briess),0.75,1
751,257,0 - None,0,1
752,257,0 - None,0,1
753,257,0 - None,0,1
937,321,Pale Ale Malt (Briess),9,19
938,321,Rye Malt (Weyermann),1,19
939,321,Chocolate Rye (Weyermann),0.25,19
940,321,'Crystal, Medium (Simpsons)',0.25,19
941,321,Special Roast (Briess),0.25,19
699,247,0 - None,0,1
700,247,0 - None,0,1
701,247,0 - None,0,1
702,247,0 - None,0,1
703,247,0 - None,0,1
704,248,0 - None,0,1
705,248,0 - None,0,1
706,248,0 - None,0,1
707,248,0 - None,0,1
708,248,0 - None,0,1
709,249,0 - None,0,1
710,249,0 - None,0,1
711,249,0 - None,0,1
712,249,0 - None,0,1
713,249,0 - None,0,1
789,265,2-Row Malt (Rahr),9,19
790,265,Pilsen (Franco-Belges),5,19
791,265,'Candi Sugar, Blonde (Soft)',1,19
792,265,CaraAroma (Weyermann),0.125,19
793,265,CaraAmber (Weyermann),0.125,19
22 changes: 11 additions & 11 deletions manual_db_backup/recipe_fermentation.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
id,recipe_id,days1,temp1,days2,temp2,days3,temp3,days4,temp4,days5,temp5
173,250,7,70,7,70,7,70,7,70,7,70
174,251,7,70,7,70,7,70,7,70,7,70
180,257,7,70,7,70,7,70,7,70,7,70
188,265,7,70,7,70,7,70,7,70,7,70
205,282,7,70,7,70,7,70,7,70,7,70
238,315,7,70,7,70,7,70,7,70,7,70
244,321,7,70,7,70,0,0,0,0,0,0
170,247,7,70,7,70,7,70,7,70,7,70
171,248,7,70,7,70,7,70,7,70,7,70
172,249,7,70,7,70,7,70,7,70,7,70
id,recipe_id,days1,temp1,days2,temp2,days3,temp3,days4,temp4,days5,temp5,user_id
173,250,7,70,7,70,7,70,7,70,7,70,1
174,251,7,70,7,70,7,70,7,70,7,70,1
180,257,7,70,7,70,7,70,7,70,7,70,1
188,265,7,70,7,70,7,70,7,70,7,70,19
205,282,7,70,7,70,7,70,7,70,7,70,1
238,315,7,70,7,70,7,70,7,70,7,70,1
244,321,7,70,7,70,0,0,0,0,0,0,19
170,247,7,70,7,70,7,70,7,70,7,70,1
171,248,7,70,7,70,7,70,7,70,7,70,1
172,249,7,70,7,70,7,70,7,70,7,70,1
62 changes: 31 additions & 31 deletions manual_db_backup/recipe_hops.csv
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
id,recipe_id,hop,weight_oz,boil_time_min
442,250,Northwest Golding,1,1
443,250,Northwest Golding,1,1
444,250,Northwest Golding,1,1
445,251,Northwest Golding,1,1
446,251,Northwest Golding,1,1
447,251,Northwest Golding,1,1
463,257,Chinook,1,50
464,257,Cascade (U.S.),1,20
465,257,Simcoe,1,5
538,282,Styrian Golding,1,60
539,282,Styrian Golding,1,15
540,282,None,0,0
571,315,Northwest Golding,1,1
572,315,Northwest Golding,1,1
573,315,Northwest Golding,1,1
487,265,Northern Brewer (German),1,60
488,265,Goldings (U.S.),0.5,5
489,265,None,0,0
589,321,Columbus,0.5,60
590,321,East Kent Goldings,1,10
591,321,None,0,0
433,247,Northwest Golding,1,1
434,247,Northwest Golding,1,1
435,247,Northwest Golding,1,1
436,248,Northwest Golding,1,1
437,248,Northwest Golding,1,1
438,248,Northwest Golding,1,1
439,249,Northwest Golding,1,1
440,249,Northwest Golding,1,1
441,249,Northwest Golding,1,1
id,recipe_id,hop,weight_oz,boil_time_min,user_id
442,250,Northwest Golding,1,1,1
443,250,Northwest Golding,1,1,1
444,250,Northwest Golding,1,1,1
445,251,Northwest Golding,1,1,1
446,251,Northwest Golding,1,1,1
447,251,Northwest Golding,1,1,1
463,257,Chinook,1,50,1
464,257,Cascade (U.S.),1,20,1
465,257,Simcoe,1,5,1
538,282,Styrian Golding,1,60,1
539,282,Styrian Golding,1,15,1
540,282,None,0,0,1
571,315,Northwest Golding,1,1,1
572,315,Northwest Golding,1,1,1
573,315,Northwest Golding,1,1,1
487,265,Northern Brewer (German),1,60,19
488,265,Goldings (U.S.),0.5,5,19
489,265,None,0,0,19
589,321,Columbus,0.5,60,19
590,321,East Kent Goldings,1,10,19
591,321,None,0,0,19
433,247,Northwest Golding,1,1,1
434,247,Northwest Golding,1,1,1
435,247,Northwest Golding,1,1,1
436,248,Northwest Golding,1,1,1
437,248,Northwest Golding,1,1,1
438,248,Northwest Golding,1,1,1
439,249,Northwest Golding,1,1,1
440,249,Northwest Golding,1,1,1
441,249,Northwest Golding,1,1,1
22 changes: 11 additions & 11 deletions manual_db_backup/recipe_mash.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
id,recipe_id,init_grain_temp,sacc_rest_temp,mash_duration,mash_thickness
175,250,70,150,60,1.25
176,251,70,150,60,1.25
182,257,70,149,60,1.25
190,265,70,150,60,1.471
207,282,70,150,60,1.25
240,315,70,150,60,1.25
246,321,70,151,60,1.471
172,247,70,150,60,1.25
173,248,70,150,60,1.25
174,249,70,150,60,1.25
id,recipe_id,init_grain_temp,sacc_rest_temp,mash_duration,mash_thickness,user_id
175,250,70,150,60,1.25,1
176,251,70,150,60,1.25,1
182,257,70,149,60,1.25,1
190,265,70,150,60,1.471,19
207,282,70,150,60,1.25,1
240,315,70,150,60,1.25,1
246,321,70,151,60,1.471,19
172,247,70,150,60,1.25,1
173,248,70,150,60,1.25,1
174,249,70,150,60,1.25,1
Loading

0 comments on commit a0e1b73

Please sign in to comment.