from dotenv import load_dotenv
load_dotenv()

from app import app, db
from app.models import User, Relationship, Notification, NotificationType, PostType, Post, Photo, Location, TaggedFriend, Comment, Like
from datetime import datetime

from random import randrange
from datetime import timedelta

def random_date():
    start = datetime.strptime('6/1/2020 1:30 PM', '%m/%d/%Y %I:%M %p')
    end = datetime.strptime('11/5/2020 4:50 AM', '%m/%d/%Y %I:%M %p')

    delta = end - start
    int_delta = (delta.days * 24 * 60 * 60) + delta.seconds
    random_second = randrange(int_delta)
    return start + timedelta(seconds=random_second)


with app.app_context():
  db.drop_all()
  db.create_all()

  ian = User(first_name = 'Ian', last_name='james', password='password', created_at=random_date(),email = 'ian@aa.io', profile_picture="https://deary.s3.us-east-2.amazonaws.com/1-intro-photo-final.jpg", cover_picture="https://deary.s3.us-east-2.amazonaws.com/25d1a22a25a664cc9f428d236c064742.jpg")
  javier = User(first_name = 'Javier', last_name='james', password='password', created_at=random_date(),email = 'javier@aa.io', profile_picture="https://deary.s3.us-east-2.amazonaws.com/2e2fac9d4a392456e511345021592dd2.jpg", cover_picture="https://deary.s3.us-east-2.amazonaws.com/funny-facebook-timeline-cover.jpg")
  dean = User(first_name = 'Dean', last_name='james', password='password', created_at=random_date(),email = 'dean@aa.io', profile_picture="https://deary.s3.us-east-2.amazonaws.com/HuXMoVlIDzauXCp-800x450-noPad.jpg", cover_picture="https://deary.s3.us-east-2.amazonaws.com/images.jpeg")
  angela = User(first_name = 'Angela', last_name='james', password='password', created_at=random_date(),email = 'angela@aa.io', profile_picture="https://deary.s3.us-east-2.amazonaws.com/Peter-Griffin-Instagram-ShockBlast-3.jpg", cover_picture="https://deary.s3.us-east-2.amazonaws.com/Just-Live-Facebook-Cover-851-x-315-768x284.jpg")
  soonmi = User(first_name = 'Soon-Mi', last_name='james', password='password', created_at=random_date(),email = 'soonmi@aa.io', profile_picture="https://deary.s3.us-east-2.amazonaws.com/pexels-photo-220453.jpeg", cover_picture="https://deary.s3.us-east-2.amazonaws.com/nature-design.jpg")
  alissa = User(first_name = 'Alissa', last_name='james', password='password', created_at=random_date(),email = 'alissa@aa.io', profile_picture="https://deary.s3.us-east-2.amazonaws.com/pexels-photo-771742.jpeg", cover_picture="https://deary.s3.us-east-2.amazonaws.com/kids-facebook-funny-and-simple-cover-photo.png")
  ammar = User(first_name = 'ammar', last_name='nassri', password='password', created_at=random_date(),email = 'ammar@gmail.com', city="Atlanta", state="GA", country="USA", bio="this is me, deal with it", profile_picture="https://deary.s3.us-east-2.amazonaws.com/thumb-211603.jpg", cover_picture="https://deary.s3.us-east-2.amazonaws.com/to_visit_my_profile_facebook_cover_1351699956.jpg")
  huda = User(first_name = 'Huda', last_name='Alghazouli', password='password', created_at=random_date(),email = 'huda@gmail.com', city="Atlanta", state="GA", country="USA", bio="Harhorata el qalb")
  kareem = User(first_name = 'kareem', last_name='nassri', password='password', created_at=random_date(),email = 'kareem@gmail.com')
  mike = User(first_name = 'mike', last_name='Doe', password='password', created_at=random_date(),email = 'mike@gmail.com')
  Jack = User(first_name = 'Jack', last_name='Doe', password='password', created_at=random_date(),email = 'jack@gmail.com')
  Will = User(first_name = 'Will', last_name='Doe', password='password', created_at=random_date(),email = 'will@gmail.com')
  Tom = User(first_name = 'Tom', last_name='Doe', password='password', created_at=random_date(),email = 'tom@gmail.com')
  John = User(first_name = 'john', last_name='Doe', password='password', created_at=random_date(),email = 'john@gmail.com')
  Jennifer = User(first_name = 'Jennifer', last_name='Doe', password='password', created_at=random_date(),email = 'jen@gmail.com')
  Sara = User(first_name = 'Sara', last_name='Doe', password='password', created_at=random_date(),email = 'sara@gmail.com')
  Lara = User(first_name = 'Lara', last_name='Doe', password='password', created_at=random_date(),email = 'lara@gmail.com')
  Thalia = User(first_name = 'Thalia', last_name='Doe', password='password', created_at=random_date(),email = 'thalia@gmail.com')
  Jude = User(first_name = 'Jude', last_name='Doe', password='password', created_at=random_date(),email = 'jude@gmail.com')
  Russel = User(first_name = 'Russel', last_name='Doe', password='password', created_at=random_date(),email = 'russel@gmail.com')
  sam = User(first_name = 'sam', last_name='Doe', password='password', created_at=random_date(),email = 'sam@gmail.com')
  ash = User(first_name = 'ash', last_name='Doe', password='password', created_at=random_date(),email = 'ash@gmail.com')
  

  relationship1 = Relationship(user_id=7, friend_id=2, action_user_id=7, status=2, friends_since=random_date())
  relationship2 = Relationship(friend_id=7, user_id=5, action_user_id=5, status=1, friends_since=random_date())
  relationship3 = Relationship(friend_id=7, user_id=6, action_user_id=6, status=1, friends_since=random_date())
  relationship4 = Relationship(friend_id=7, user_id=3, action_user_id=3, status=1, friends_since=random_date())
  relationship5 = Relationship(user_id=4, friend_id=7, action_user_id=4, status=1, friends_since=random_date())
  # relationship5 = Relationship(user_id=10, friend_id=7, action_user_id=10, status=1, friends_since=random_date())
  # relationship5 = Relationship(user_id=14, friend_id=7, action_user_id=14, status=1, friends_since=random_date())
  # relationship5 = Relationship(user_id=16, friend_id=7, action_user_id=16, status=1, friends_since=random_date())
  # relationship5 = Relationship(user_id=11, friend_id=7, action_user_id=11, status=1, friends_since=random_date())
  
  post_types1 = PostType(type="work")
  post_types2 = PostType(type="education")
  post_types3 = PostType(type="relationship")
  post_types4 = PostType(type="home")
  post_types5 = PostType(type="family")
  post_types6 = PostType(type="travel")
  post_types7 = PostType(type="activities")
  post_types8 = PostType(type="health")
  post_types9 = PostType(type="achievements")
  post_types10 = PostType(type="rememberance")
  
  # commented
  # liked
  # added you as a friend
  # 
  notification_type1 = NotificationType(type="comment")
  notification_type2 = NotificationType(type="like")
  notification_type3 = NotificationType(type="add")

  notification1 = Notification(friend_id=4,user_id=7,type_id=3, status=2, created_at=random_date())
  notification2 = Notification(friend_id=1,user_id=7,type_id=1, status=2, post_id=1, created_at=random_date())
  notification3 = Notification(friend_id=2,user_id=7,type_id=1, status=2, post_id=1, created_at=random_date())
  notification4 = Notification(friend_id=3,user_id=7,type_id=1, status=2, post_id=1, created_at=random_date())
  notification5 = Notification(friend_id=5,user_id=7,type_id=2, status=2, post_id=8, created_at=random_date())
  notification6 = Notification(friend_id=6,user_id=7,type_id=2, status=2, post_id=8, created_at=random_date())
  notification7 = Notification(friend_id=1,user_id=7,type_id=2, status=2, post_id=15, created_at=random_date())
  notification8 = Notification(friend_id=2,user_id=7,type_id=2, status=2, post_id=15, created_at=random_date())
  notification9 = Notification(friend_id=3,user_id=7,type_id=2, status=2, post_id=15, created_at=random_date())
  notification10 = Notification(friend_id=5,user_id=7,type_id=2, status=1, post_id=15, created_at=random_date())
  notification11 = Notification(friend_id=6,user_id=7,type_id=2, status=1, post_id=15, created_at=random_date())
  notification12 = Notification(friend_id=1,user_id=7,type_id=2, status=1, post_id=8, created_at=random_date())
  notification13 = Notification(friend_id=2,user_id=7,type_id=1, status=1, post_id=8, created_at=random_date())
  
  post1 = Post(user_id=7, description="some weird description, bla bla bla", type_id=1, location_id=2, created_at=random_date())
  post2 = Post(user_id=1, description="some weird description, bla bla bla", type_id=2, location_id=1, created_at=random_date())
  post3 = Post(user_id=2, description="some weird description, bla bla bla", type_id=3, created_at=random_date())
  post4 = Post(user_id=3, description="some weird description, bla bla bla", type_id=4, location_id=3,created_at=random_date())
  post5 = Post(user_id=4, description="some weird description, bla bla bla", type_id=5, location_id=4,created_at=random_date())
  post6 = Post(user_id=2, description="some weird description, bla bla bla", type_id=6, created_at=random_date())
  post7 = Post(user_id=6, description="some weird description, bla bla bla", type_id=7, location_id=5,created_at=random_date())
  post8 = Post(user_id=7, description="some weird description, bla bla bla", type_id=8, created_at=random_date())
  post9 = Post(user_id=3, description="some weird description, bla bla bla", type_id=9, location_id=4,created_at=random_date())
  post10 = Post(user_id=2, description="some weird description, bla bla bla", type_id=10, created_at=random_date())
  post11 = Post(user_id=3, description="some weird description, bla bla bla", type_id=1, location_id=1,created_at=random_date())
  post12 = Post(user_id=7, description="some weird description, bla bla bla", type_id=2, location_id=2,created_at=random_date())
  post13 = Post(user_id=2, description="some weird description, bla bla bla", type_id=3, created_at=random_date())
  post14 = Post(user_id=2, description="some weird description, bla bla bla", type_id=4, location_id=3,created_at=random_date())
  post15 = Post(user_id=7, description="some weird description, bla bla bla", type_id=5, created_at=random_date())
  # post16 = Post(user_id=8, description="some weird description, bla bla bla", type_id=2, created_at=random_date())
  # post17 = Post(user_id=9, description="some weird description, bla bla bla", type_id=3, created_at=random_date())
  # post18 = Post(user_id=10, description="some weird description, bla bla bla", type_id=4, created_at=random_date())
  # post19 = Post(user_id=11, description="some weird description, bla bla bla", type_id=5, created_at=random_date())
  # post20 = Post(user_id=12, description="some weird description, bla bla bla", type_id=6, created_at=random_date())
  # post21 = Post(user_id=13, description="some weird description, bla bla bla", type_id=7, created_at=random_date())
  # post22 = Post(user_id=14, description="some weird description, bla bla bla", type_id=8, created_at=random_date())
  # post23 = Post(user_id=15, description="some weird description, bla bla bla", type_id=9, created_at=random_date())
  # post24 = Post(user_id=16, description="some weird description, bla bla bla", type_id=1, created_at=random_date())
  # post25 = Post(user_id=17, description="some weird description, bla bla bla", type_id=2, created_at=random_date())
  # post26 = Post(user_id=18, description="some weird description, bla bla bla", type_id=3, created_at=random_date())
  # post27 = Post(user_id=19, description="some weird description, bla bla bla", type_id=4, created_at=random_date())
  # post28 = Post(user_id=20, description="some weird description, bla bla bla", type_id=5, created_at=random_date())
  # post29 = Post(user_id=21, description="some weird description, bla bla bla", type_id=6, created_at=random_date())
  # post30 = Post(user_id=22, description="some weird description, bla bla bla", type_id=7, created_at=random_date())
  # post31 = Post(user_id=8, description="some weird description, bla bla bla", type_id=8, created_at=random_date())
  # post32 = Post(user_id=9, description="some weird description, bla bla bla", type_id=9, created_at=random_date())
  # post33 = Post(user_id=10, description="some weird description, bla bla bla", type_id=1, created_at=random_date())
  # post34 = Post(user_id=11, description="some weird description, bla bla bla", type_id=2, created_at=random_date())
  # post35 = Post(user_id=12, description="some weird description, bla bla bla", type_id=3, created_at=random_date())
  
  photo1 = Photo(path="https://deary.s3.us-east-2.amazonaws.com/5ad2252c1ef10ed961fe23a88d63e613.jpg", post_id=1)
  photo2 = Photo(path="https://deary.s3.us-east-2.amazonaws.com/5bb48b07fa6e3840bb3afa2bc821b882.jpg", post_id=3)
  photo3 = Photo(path="https://deary.s3.us-east-2.amazonaws.com/Random-Funny-Pictures-14-08-2018-27.jpg", post_id=4)
  photo4 = Photo(path="https://deary.s3.us-east-2.amazonaws.com/cover1.jpg", post_id=6)
  photo5 = Photo(path="https://deary.s3.us-east-2.amazonaws.com/flnirv5p08x11.jpg", post_id=7)
  photo6 = Photo(path="https://deary.s3.us-east-2.amazonaws.com/going+to+work+majorgeeks.jpg", post_id=9)
  photo7 = Photo(path="https://deary.s3.us-east-2.amazonaws.com/photo-1494253109108-2e30c049369b.jpeg", post_id=11)
  photo8 = Photo(path="https://deary.s3.us-east-2.amazonaws.com/photo-1508138221679-760a23a2285b.jpeg", post_id=12)
  photo9 = Photo(path="https://deary.s3.us-east-2.amazonaws.com/random-pictures-116.jpg", post_id=13)
  photo10 = Photo(path="https://deary.s3.us-east-2.amazonaws.com/random.jpg", post_id=15)

  location1 = Location(location="Atlanta, GA USA")
  location2 = Location(location="New York, NY USA")
  location3 = Location(location="Madrid, Spain")
  location4 = Location(location="London, England")
  location5 = Location(location="Cairo, Egypt")

  tagged_friend1 = TaggedFriend(user_id=1, post_id=1)
  tagged_friend2 = TaggedFriend(user_id=2, post_id=1)
  tagged_friend3 = TaggedFriend(user_id=3, post_id=4)
  tagged_friend4 = TaggedFriend(user_id=4, post_id=3)
  tagged_friend5 = TaggedFriend(user_id=5, post_id=9)
  tagged_friend6 = TaggedFriend(user_id=6, post_id=6)

  comment1= Comment(comment="this is some test comment 1", post_id=1, user_id=1, created_at=random_date())
  comment2= Comment(comment="this is some test comment 2", post_id=2, user_id=2, created_at=random_date())
  comment3= Comment(comment="this is some test comment 3", post_id=3, user_id=3, created_at=random_date())
  comment4= Comment(comment="this is some test comment 4", post_id=4, user_id=4, created_at=random_date())
  comment5= Comment(comment="this is some test comment 5", post_id=5, user_id=5, created_at=random_date())
  comment6= Comment(comment="this is some test comment 6", post_id=6, user_id=6, created_at=random_date())
  comment7= Comment(comment="this is some test comment 7", post_id=7, user_id=7, created_at=random_date())
  comment8= Comment(comment="this is some test comment 8", post_id=8, user_id=1, created_at=random_date())
  comment9= Comment(comment="this is some test comment 9", post_id=1, user_id=2, created_at=random_date())
  comment10= Comment(comment="this is some test comment 10", post_id=1, user_id=3, created_at=random_date())
  comment11= Comment(comment="this is some test comment 11", post_id=2, user_id=4, created_at=random_date())
  comment12= Comment(comment="this is some test comment 12", post_id=2, user_id=5, created_at=random_date())
  comment13= Comment(comment="this is some test comment 13", post_id=2, user_id=6, created_at=random_date())
  comment14= Comment(comment="this is some test comment 14", post_id=2, user_id=7, created_at=random_date())
  comment15= Comment(comment="this is some test comment 15", post_id=3, user_id=1, created_at=random_date())
  comment16= Comment(comment="this is some test comment 16", post_id=9, user_id=2, created_at=random_date())
  comment17= Comment(comment="this is some test comment 17", post_id=10, user_id=3, created_at=random_date())
  comment18= Comment(comment="this is some test comment 18", post_id=11, user_id=4, created_at=random_date())
  comment19= Comment(comment="this is some test comment 19", post_id=11, user_id=5, created_at=random_date())
  
  like1= Like(post_id=3, user_id=1)
  like2= Like(post_id=4, user_id=2)
  like3= Like(post_id=3, user_id=3)
  like4= Like(post_id=4, user_id=4)
  like5= Like(post_id=3, user_id=5)
  like6= Like(post_id=4, user_id=6)
  like7= Like(post_id=4, user_id=7)
  like8= Like(post_id=4, user_id=1)
  like9= Like(post_id=2, user_id=2)
  like10= Like(post_id=6, user_id=3)
  like11= Like(post_id=8, user_id=4)
  like12= Like(post_id=8, user_id=5)
  like13= Like(post_id=8, user_id=6)
  like14= Like(post_id=6, user_id=7)
  like15= Like(post_id=9, user_id=1)
  like16= Like(post_id=9, user_id=2)
  like17= Like(post_id=9, user_id=3)
  like18= Like(post_id=9, user_id=4)
  like19= Like(post_id=9, user_id=5)
  like20= Like(post_id=9, user_id=6)
  like21= Like(post_id=9, user_id=7)
  like22= Like(post_id=10, user_id=1)
  like23= Like(post_id=10, user_id=2)
  like24= Like(post_id=10, user_id=3)
  like25= Like(post_id=10, user_id=4)
  like26= Like(post_id=10, user_id=5)
  like27= Like(post_id=10, user_id=6)
  like28= Like(post_id=10, user_id=7)
  like29= Like(post_id=10, user_id=1)
  like30= Like(post_id=15, user_id=2)
  like31= Like(post_id=13, user_id=3)
  like32= Like(post_id=13, user_id=4)
  like33= Like(post_id=14, user_id=5)
  like34= Like(post_id=14, user_id=6)
  like35= Like(post_id=13, user_id=7)
  like36= Like(post_id=14, user_id=1)
  like37= Like(post_id=13, user_id=2)
  like38= Like(post_id=14, user_id=3)
  like39= Like(post_id=13, user_id=4)
  like40= Like(post_id=13, user_id=5)
  like41= Like(post_id=13, user_id=6)
  like42= Like(post_id=13, user_id=7)
  like43= Like(post_id=13, user_id=1)
  like44= Like(post_id=15, user_id=2)
  like45= Like(post_id=15, user_id=3)
  like46= Like(post_id=15, user_id=4)
  like47= Like(post_id=15, user_id=5)
  like48= Like(post_id=15, user_id=6)
  like49= Like(post_id=15, user_id=7)
  like50= Like(post_id=3, user_id=1)
  like51= Like(post_id=3, user_id=2)
  like52= Like(post_id=3, user_id=3)
  like53= Like(post_id=3, user_id=4)
  like54= Like(post_id=3, user_id=5)
  like55= Like(post_id=4, user_id=6)
  like56= Like(post_id=4, user_id=7)
  like57= Like(post_id=4, user_id=1)
  
  db.session.add(ian)
  db.session.add(javier)
  db.session.add(dean)
  db.session.add(angela)
  db.session.add(soonmi)
  db.session.add(alissa)
  db.session.add(ammar)
  db.session.add(huda)
  # db.session.add(kareem)
  # db.session.add(mike)
  # db.session.add(Jack)
  # db.session.add(Will)
  # db.session.add(Tom)
  # db.session.add(John)
  # db.session.add(Jennifer)
  # db.session.add(Sara)
  # db.session.add(Lara)
  # db.session.add(Thalia)
  # db.session.add(Jude)
  # db.session.add(Russel)
  # db.session.add(sam)
  # db.session.add(ash)

  db.session.add(relationship1)
  db.session.add(relationship2)
  db.session.add(relationship3)
  db.session.add(relationship4)
  db.session.add(relationship5)

  db.session.add(post_types1)
  db.session.add(post_types2)
  db.session.add(post_types3)
  db.session.add(post_types4)
  db.session.add(post_types5)
  db.session.add(post_types6)
  db.session.add(post_types7)
  db.session.add(post_types8)
  db.session.add(post_types9)
  db.session.add(post_types10)

  db.session.add(post1)
  db.session.add(post2)
  db.session.add(post3)
  db.session.add(post4)
  db.session.add(post5)
  db.session.add(post6)
  db.session.add(post7)
  db.session.add(post8)
  db.session.add(post9)
  db.session.add(post10)
  db.session.add(post11)
  db.session.add(post12)
  db.session.add(post13)
  db.session.add(post14)
  db.session.add(post15)
  # db.session.add(post16)
  # db.session.add(post17)
  # db.session.add(post18)
  # db.session.add(post19)
  # db.session.add(post20)
  # db.session.add(post21)
  # db.session.add(post22)
  # db.session.add(post23)
  # db.session.add(post24)
  # db.session.add(post25)
  # db.session.add(post26)
  # db.session.add(post27)
  # db.session.add(post28)
  # db.session.add(post29)
  # db.session.add(post30)
  # db.session.add(post31)
  # db.session.add(post32)
  # db.session.add(post33)
  # db.session.add(post34)
  # db.session.add(post35)

  db.session.add(comment1)
  db.session.add(comment2)
  db.session.add(comment3)
  db.session.add(comment4)
  db.session.add(comment5)
  db.session.add(comment6)
  db.session.add(comment7)
  db.session.add(comment8)
  db.session.add(comment9)
  db.session.add(comment10)
  db.session.add(comment11)
  db.session.add(comment12)
  db.session.add(comment13)
  db.session.add(comment14)
  db.session.add(comment15)
  db.session.add(comment16)
  db.session.add(comment17)
  db.session.add(comment18)
  db.session.add(comment19)

  db.session.add(like1)
  db.session.add(like2)
  db.session.add(like3)
  db.session.add(like4)
  db.session.add(like5)
  db.session.add(like6)
  db.session.add(like7)
  db.session.add(like8)
  db.session.add(like9)
  db.session.add(like10)
  db.session.add(like11)
  db.session.add(like12)
  db.session.add(like13)
  db.session.add(like14)
  db.session.add(like15)
  db.session.add(like16)
  db.session.add(like17)
  db.session.add(like18)
  db.session.add(like19)
  db.session.add(like20)
  db.session.add(like21)
  db.session.add(like22)
  db.session.add(like23)
  db.session.add(like24)
  db.session.add(like25)
  db.session.add(like26)
  db.session.add(like27)
  db.session.add(like28)
  db.session.add(like29)
  db.session.add(like30)
  db.session.add(like31)
  db.session.add(like32)
  db.session.add(like33)
  db.session.add(like34)
  db.session.add(like35)
  db.session.add(like36)
  db.session.add(like37)
  db.session.add(like38)
  db.session.add(like39)
  db.session.add(like40)
  db.session.add(like41)
  db.session.add(like42)
  db.session.add(like43)
  db.session.add(like44)
  db.session.add(like45)
  db.session.add(like46)
  db.session.add(like47)
  db.session.add(like48)
  db.session.add(like49)
  db.session.add(like50)
  db.session.add(like51)
  db.session.add(like52)
  db.session.add(like53)
  db.session.add(like54)
  db.session.add(like55)
  db.session.add(like56)
  db.session.add(like57)

  db.session.add(photo1)
  db.session.add(photo2)
  db.session.add(photo3)
  db.session.add(photo4)
  db.session.add(photo5)
  db.session.add(photo6)
  db.session.add(photo7)
  db.session.add(photo8)
  db.session.add(photo9)
  db.session.add(photo10)

  db.session.add(notification1)
  db.session.add(notification2)
  db.session.add(notification3)
  db.session.add(notification4)
  db.session.add(notification5)
  db.session.add(notification6)
  db.session.add(notification7)
  db.session.add(notification8)
  db.session.add(notification9)
  db.session.add(notification10)
  db.session.add(notification11)
  db.session.add(notification12)
  db.session.add(notification13)

  db.session.add(location1)
  db.session.add(location2)
  db.session.add(location3)
  db.session.add(location4)
  db.session.add(location5)

  db.session.add(tagged_friend1)
  db.session.add(tagged_friend2)
  db.session.add(tagged_friend3)
  db.session.add(tagged_friend4)
  db.session.add(tagged_friend5)
  db.session.add(tagged_friend6)

  db.session.add(notification_type1)
  db.session.add(notification_type2)
  db.session.add(notification_type3)

  db.session.commit()
