
from lumberjack import app, db
from lumberjack.models.user import *
from lumberjack.models.user import User
from lumberjack.models.workout import Workout
from lumberjack.models.exercise import Exercise
from lumberjack.models.exercise_tag import ExerciseTag
from datetime import datetime, timedelta, date, time
from lumberjack.models.user_measurement import UserMeasurement

u1 = User("Kyle", "123")
db.session.add(u1)
db.session.add(u1.follow(u1))
utcnow = datetime.utcnow()
p1 = Newsfeed(body = "Has Joined Lumberjack", timestamp = utcnow + timedelta(seconds = 1), user_id = 1, userName = "Kyle")
db.session.add(p1)

u2 = User("Jeremy", "123")
db.session.add(u2)
db.session.add(u2.follow(u2))
utcnow = datetime.utcnow()
p2 = Newsfeed(body = "Has Joined Lumberjack", timestamp = utcnow + timedelta(seconds = 1), user_id = 2, userName = "Jeremy")
db.session.add(p2)

u3 = User("Andy", "123")
db.session.add(u3)
db.session.add(u3.follow(u3))
utcnow = datetime.utcnow()
p3 = Newsfeed(body = "Has Joined Lumberjack", timestamp = utcnow + timedelta(seconds = 1), user_id = 3, userName = "Andy")
db.session.add(p3)

u4 = User("Shaw", "123")
db.session.add(u4)
db.session.add(u4.follow(u4))
utcnow = datetime.utcnow()
p4 = Newsfeed(body = "Has Joined Lumberjack", timestamp = utcnow + timedelta(seconds = 1), user_id = 4, userName = "Shaw")
db.session.add(p4)

u5 = User("Zapp", "123")
db.session.add(u5)
db.session.add(u5.follow(u5))
utcnow = datetime.utcnow()
p5 = Newsfeed(body = "Has Joined Lumberjack", timestamp = utcnow + timedelta(seconds = 1), user_id = 5, userName = "Zapp")
db.session.add(p5)

u6 = User("Bradley", "123")
db.session.add(u6)
db.session.add(u6.follow(u6))
utcnow = datetime.utcnow()
p6 = Newsfeed(body = "Has Joined Lumberjack", timestamp = utcnow + timedelta(seconds = 1), user_id = 6, userName = "Bradley")
db.session.add(p6)

u7 = User("tester", "123")
db.session.add(u7)
db.session.add(u7.follow(u7))
utcnow = datetime.utcnow()
p7 = Newsfeed(body = "Has Joined Lumberjack", timestamp = utcnow + timedelta(seconds = 1), user_id = 7, userName = "tester")
db.session.add(p7)

u8 = User("Cameron", "123")
db.session.add(u8)
db.session.add(u8.follow(u8))
utcnow = datetime.utcnow()
p8 = Newsfeed(body = "Has Joined Lumberjack", timestamp = utcnow + timedelta(seconds = 1), user_id = 8, userName = "Cameron")
db.session.add(p8)

u9 = User("seleniumTester", "123")
db.session.add(u9)
db.session.add(u9.follow(u9))
utcnow = datetime.utcnow()
p9 = Newsfeed(body = "Has joined Lumberjack", timestamp = utcnow + timedelta(seconds = 1), user_id = 9, userName = "seleniumTester")
db.session.add(p9)

eTag1 = ExerciseTag(name = "Running", unit = "Minutes")
eTag2 = ExerciseTag(name = "Walking", unit = "Minutes")
eTag3 = ExerciseTag(name = "Cycling", unit = "Minutes")
eTag4 = ExerciseTag(name = "Bicep Curls", unit = "Reps")
eTag5 = ExerciseTag(name = "Squats", unit = "Reps")
eTag6 = ExerciseTag(name = "Bench Presses", unit = "Reps")
eTag7 = ExerciseTag(name = "Skiing", unit = "Minutes")
eTag8 = ExerciseTag(name = "Swimming", unit = "Minutes")
eTag9 = ExerciseTag(name = "Jumping Jacks", unit = "Minutes")

db.session.add(eTag1)
db.session.add(eTag2)
db.session.add(eTag3)
db.session.add(eTag4)
db.session.add(eTag5)
db.session.add(eTag6)
db.session.add(eTag7)
db.session.add(eTag8)
db.session.add(eTag9)
db.session.commit()

w1 = Workout(user_id=1,parent_user_id=1, name="Kyle's Ultimate Work", description="Build both size and strength", level="Hard", is_public=True, is_likeable=True, is_commentable=True)
db.session.add(w1)
db.session.commit()
e = Exercise(workOutId=w1.id, eTagId=eTag4.id, order="1", amount="5", additionalInfo="No Additional Info")
db.session.add(e)
e = Exercise(workOutId=w1.id, eTagId=eTag5.id, order="1", amount="8", additionalInfo="No Additional Info")
db.session.add(e)
e = Exercise(workOutId=w1.id, eTagId=eTag6.id, order="1", amount="8", additionalInfo="No Additional Info")
db.session.add(e)
p9 = Newsfeed(body = "Has added a workout: Kyle's Ultimate Work", timestamp = utcnow + timedelta(seconds = 1), user_id = 1, userName = "Kyle")
db.session.add(p9)

w2 = Workout(user_id=2,parent_user_id=2, name="Jeremy's Meh Workout", description="How would a spy like James Bond stay at his peak? This workout provides you with the specifics to look great and have the athleticism to match.", level="Medium", is_public=True, is_likeable=True, is_commentable=True)
db.session.add(w2)
db.session.commit()
exercise2 = Exercise(workOutId=w2.id, eTagId=eTag2.id, order="1", amount="5", additionalInfo="No Additional Info")
db.session.add(exercise2)
p10 = Newsfeed(body = "Has added a workout: Jeremy's Meh Workout", timestamp = utcnow + timedelta(seconds = 1), user_id = 2, userName = "Jeremy")
db.session.add(p10)

w3 = Workout(user_id=3,parent_user_id=3, name="Andy's Soccer Workout", description="2 days after Super Bowl 45 AJ Hawk lay on an operating table to repair his wrist. 3 weeks after having the pins removed, A.J. put on a training display.", level="Hard", is_public=True, is_likeable=True, is_commentable=True)
db.session.add(w3)
db.session.commit()
exercise3 = Exercise(workOutId=w3.id, eTagId=eTag3.id, order="1", amount="5", additionalInfo="No Additional Info")
db.session.add(exercise3)
p11 = Newsfeed(body = "Has added a workout: Andy's Soccer Workout", timestamp = utcnow + timedelta(seconds = 1), user_id =3, userName = "Andy")
db.session.add(p11)

w4 = Workout(user_id=4,parent_user_id=4, name="Shaw's Lazy Workout", description="You've seen the movie 300, now get the body. This is the intense 300 Spartan workout used by the cast of the movie that delivers results.", level="Easy", is_public=True, is_likeable=True, is_commentable=True)
db.session.add(w4)
db.session.commit()
exercise4 = Exercise(workOutId=w4.id, eTagId=eTag4.id, order="1", amount="5", additionalInfo="No Additional Info")
db.session.add(exercise4)
p12 = Newsfeed(body = "Has added a workout: Shaw's Lazy Workout", timestamp = utcnow + timedelta(seconds = 1), user_id = 4, userName = "Shaw")
db.session.add(p12)

d = date(2013, 02, 13)
t = time(2, 52)
wh1 = WorkoutHistory(8, 1, datetime.combine(d,t), "I really have't work out out in a while. I need to get into shape so I cant do the manitoba marathon. Cannot wait!!!", True)
db.session.add(wh1)

d = date(2013, 02, 14)
t = time(2, 55)
wh2 = WorkoutHistory(8, 2, datetime.combine(d,t), "Things have been getting better, my legs are not as sore as there were when I first started but i find that I do better when running witha partner", True)
db.session.add(wh2)

d = date(2013, 02, 15)
t = time(2, 57)
wh3 = WorkoutHistory(8, 1, datetime.combine(d,t), "Just did a kilometer more than the length of the Manitoba Marathon", True)
db.session.add(wh3)

db.session.commit()
f1 = u1.follow(u2)
db.session.add(f1)
f8 = u1.follow(u3)
db.session.add(f8)
f15 = u5.follow(u7)
db.session.add(f15)
f16 = u5.follow(u6)
db.session.add(f16)
f18 = u5.follow(u4)
db.session.add(f18)
f19 = u5.follow(u3)
db.session.add(f19)
f20 = u5.follow(u1)
db.session.add(f20)
f21 = u5.follow(u8)
db.session.add(f21)
f10 = u5.follow(u2)
db.session.add(f10)
f2 = u3.follow(u2)
db.session.add(f2)
f3 = u4.follow(u2)
db.session.add(f3)
f9 = u4.follow(u1)
db.session.add(f9)
f4 = u2.follow(u5)
db.session.add(f4)
f22 = u2.follow(u8)
db.session.add(f21)
f5 = u6.follow(u2)
db.session.add(f5)
f13 = u6.follow(u8)
db.session.add(f13)
f6 = u7.follow(u2)
db.session.add(f6)
f14 = u7.follow(u2)
db.session.add(f14)
f12 = u7.follow(u8)
db.session.add(f12)
f7 = u8.follow(u2)
db.session.add(f7)
db.session.commit()

measurement_list = []
measurement_list.append(UserMeasurement(user_id=u9.id, type="distance ran", value=2, unit="miles", date=datetime.now()))
measurement_list.append(UserMeasurement(user_id=u9.id, type="distance ran", value=5, unit="miles", date=datetime.now() + timedelta(minutes =10)))
measurement_list.append(UserMeasurement(user_id=u9.id, type="distance ran", value=23, unit="miles",date=datetime.now() + timedelta(minutes =15)))
measurement_list.append(UserMeasurement(user_id=u9.id, type="height", value=170, unit="cm", date=datetime.now()))
measurement_list.append(UserMeasurement(user_id=u9.id, type="height", value=170, unit="cm", date=datetime.now() + timedelta(minutes =3)))
measurement_list.append(UserMeasurement(user_id=u9.id, type="weight", value=170, unit="lbs", date=datetime.now() + timedelta(minutes = 20)))
for measurement in measurement_list:
    UserMeasurement.save_to_db(measurement)
print("Successfully added entries to the Database.")
