Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- username = request.form['user']
- user = db_interaction.get_user_info(username)
- f = ["a", "b", "c", "d"]
- i = 0
- id = 0
- for field in user:
- if i==3:
- id = field
- break
- else:
- f[i] = str(field)
- i = i+1
- uid = str(db_interaction.get_user_id(username))
- j = uid.replace('(', '')
- d = j.replace(')', '')
- id = d.replace(',', '')
- notif = Notification()
- link = notif.get_subscribe_link(id)
- session['user'] = username
- session['password'] = f[1]
- session['email'] = f[2]
- session['id'] = id
- session['link'] = link
- session['auth'] = "authenticated"
- if db_interaction.get_date(username) is not None: #date in db is not null, i.e. we have data from previous days or today
- date_db = db_interaction.get_date(username)
- uid = str(date_db)
- j = uid.replace('(', '')
- d = j.replace(')', '')
- ddb = d.replace(',', '')
- date_curr = datetime.datetime.today().day
- if str(date_curr) != ddb: #data from previous day
- db_interaction.set_sleeps(username, sleep_timestamp[0], sleep_timestamp[1], sleep_timestamp[2], sleep_timestamp[3], sleep_timestamp[4], sleep_timestamp[5], sleep_timestamp[6])
- db_interaction.set_wakes(username, wake_timestamp[0], wake_timestamp[1], wake_timestamp[2], wake_timestamp[3], wake_timestamp[4], wake_timestamp[5], wake_timestamp[6])
- db_interaction.set_kcals(username, kcal[0], kcal[1], kcal[2], kcal[3], kcal[4], kcal[5], kcal[6])
- session['auth'] = "authenticated"
- return render_template('personal.html', user=username, password=f[1], email=f[2], id=f[3], link=link, auth="authenticated"
- day7="7daysAgo", day6="6daysAgo", day5="5daysAgo", day4="4daysAgo", day3="3daysAgo", day2="2daysAgo", day1="1dayAgo",
- cal7=kcal[6], cal6=kcal[5], cal5=kcal[4], cal4=kcal[3], cal3=kcal[2], cal2=kcal[1], cal1=kcal[0],
- sleep7=sleep_timestamp[6], sleep6=sleep_timestamp[5], sleep5=sleep_timestamp[4], sleep4=sleep_timestamp[3], sleep3=sleep_timestamp[2],
- sleep2=sleep_timestamp[1], sleep1=sleep_timestamp[0], wake7=wake_timestamp[6], wake6=wake_timestamp[5], wake5=wake_timestamp[4],
- wake3=wake_timestamp[2], wake2=wake_timestamp[1], wake1=wake_timestamp[0], wake4=wake_timestamp[3])
- else: #data has been saved in the same day
- sleep = db_interaction.get_sleep(username)
- uid = str(sleep)
- j = uid.replace('(', '')
- d = j.replace(')', '')
- sleep = d.replace(',', '')
- wake = db_interaction.get_wake(username)
- uid = str(wake)
- j = uid.replace('(', '')
- d = j.replace(')', '')
- wake = d.replace(',', '')
- if sleep is None: #algorithm hasn't been run yet
- db_interaction.set_sleeps(username, sleep_timestamp[0], sleep_timestamp[1], sleep_timestamp[2], sleep_timestamp[3], sleep_timestamp[4], sleep_timestamp[5], sleep_timestamp[6])
- db_interaction.set_wakes(username, wake_timestamp[0], wake_timestamp[1], wake_timestamp[2], wake_timestamp[3], wake_timestamp[4], wake_timestamp[5], wake_timestamp[6])
- db_interaction.set_kcals(username, kcal[0], kcal[1], kcal[2], kcal[3], kcal[4], kcal[5], kcal[6])
- session['auth'] = "authenticated"
- return render_template('personal.html', user=username, password=f[1], email=f[2], id=f[3], link=link, auth="authenticated"
- day7="7daysAgo", day6="6daysAgo", day5="5daysAgo", day4="4daysAgo", day3="3daysAgo", day2="2daysAgo", day1="1dayAgo",
- cal7=kcal[6], cal6=kcal[5], cal5=kcal[4], cal4=kcal[3], cal3=kcal[2], cal2=kcal[1], cal1=kcal[0],
- sleep7=sleep_timestamp[6], sleep6=sleep_timestamp[5], sleep5=sleep_timestamp[4], sleep4=sleep_timestamp[3], sleep3=sleep_timestamp[2],
- sleep2=sleep_timestamp[1], sleep1=sleep_timestamp[0], wake7=wake_timestamp[6], wake6=wake_timestamp[5], wake5=wake_timestamp[4],
- wake3=wake_timestamp[2], wake2=wake_timestamp[1], wake1=wake_timestamp[0], wake4=wake_timestamp[3])
- else: #algorithm ran
- db_interaction.set_sleeps(username, sleep_timestamp[0], sleep_timestamp[1], sleep_timestamp[2], sleep_timestamp[3], sleep_timestamp[4], sleep_timestamp[5], sleep_timestamp[6])
- db_interaction.set_wakes(username, wake_timestamp[0], wake_timestamp[1], wake_timestamp[2], wake_timestamp[3], wake_timestamp[4], wake_timestamp[5], wake_timestamp[6])
- db_interaction.set_kcals(username, kcal[0], kcal[1], kcal[2], kcal[3], kcal[4], kcal[5], kcal[6])
- session['auth'] = "authenticated"
- session['sleep'] = sleep
- session['wake'] = wake
- return render_template('personal_page.html', user=username, password=f[1], email=f[2], id=f[3], link=link, auth="authenticated", sleep=sleep, wake=wake,
- day7="7daysAgo", day6="6daysAgo", day5="5daysAgo", day4="4daysAgo", day3="3daysAgo", day2="2daysAgo", day1="1dayAgo",
- cal7=kcal[6], cal6=kcal[5], cal5=kcal[4], cal4=kcal[3], cal3=kcal[2], cal2=kcal[1], cal1=kcal[0],
- sleep7=sleep_timestamp[6], sleep6=sleep_timestamp[5], sleep5=sleep_timestamp[4], sleep4=sleep_timestamp[3], sleep3=sleep_timestamp[2],
- sleep2=sleep_timestamp[1], sleep1=sleep_timestamp[0], wake7=wake_timestamp[6], wake6=wake_timestamp[5], wake5=wake_timestamp[4],
- wake3=wake_timestamp[2], wake2=wake_timestamp[1], wake1=wake_timestamp[0], wake4=wake_timestamp[3])
- else:
- db_interaction.set_sleeps(username, sleep_timestamp[0], sleep_timestamp[1], sleep_timestamp[2], sleep_timestamp[3], sleep_timestamp[4], sleep_timestamp[5], sleep_timestamp[6])
- db_interaction.set_wakes(username, wake_timestamp[0], wake_timestamp[1], wake_timestamp[2], wake_timestamp[3], wake_timestamp[4], wake_timestamp[5], wake_timestamp[6])
- db_interaction.set_kcals(username, kcal[0], kcal[1], kcal[2], kcal[3], kcal[4], kcal[5], kcal[6])
- session['auth'] = "authenticated"
- return render_template('personal.html', user=username, password=f[1], email=f[2], id=f[3], link=link, auth="authenticated"
- day7="7daysAgo", day6="6daysAgo", day5="5daysAgo", day4="4daysAgo", day3="3daysAgo", day2="2daysAgo", day1="1dayAgo",
- cal7=kcal[6], cal6=kcal[5], cal5=kcal[4], cal4=kcal[3], cal3=kcal[2], cal2=kcal[1], cal1=kcal[0],
- sleep7=sleep_timestamp[6], sleep6=sleep_timestamp[5], sleep5=sleep_timestamp[4], sleep4=sleep_timestamp[3], sleep3=sleep_timestamp[2],
- sleep2=sleep_timestamp[1], sleep1=sleep_timestamp[0], wake7=wake_timestamp[6], wake6=wake_timestamp[5], wake5=wake_timestamp[4],
- wake3=wake_timestamp[2], wake2=wake_timestamp[1], wake1=wake_timestamp[0], wake4=wake_timestamp[3])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement