Compare commits
No commits in common. "390d43757804c1e340e104334c5e233d249f2a26" and "64275725865d5e769af88bac7afabcab9429ede0" have entirely different histories.
390d437578
...
6427572586
@ -1,4 +1,4 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
@ -100,26 +100,6 @@ def get_habits(user_id: int):
|
|||||||
return habits
|
return habits
|
||||||
|
|
||||||
|
|
||||||
def get_heatmap_value(user_id: int, days: int):
|
|
||||||
date = (datetime.now() - timedelta(days=days)).date()
|
|
||||||
print(date)
|
|
||||||
query = f"SELECT id FROM habits WHERE user_id = {user_id};"
|
|
||||||
query2 = f"SELECT habits.id FROM habits, habit_trackings WHERE habits.user_id = {user_id} AND habits.created_at LIKE '{date}%' AND habit_trackings.habit_id = habits.id;"
|
|
||||||
print(query2)
|
|
||||||
conn = con3()
|
|
||||||
cursor = conn.cursor()
|
|
||||||
cursor.execute(query)
|
|
||||||
all_habits = cursor.fetchall()
|
|
||||||
cursor.execute(query2)
|
|
||||||
checked_habits = cursor.fetchall()
|
|
||||||
count = len(all_habits)
|
|
||||||
print(count)
|
|
||||||
count2 = len(checked_habits)
|
|
||||||
print(count2)
|
|
||||||
conn.close()
|
|
||||||
return int(count2 / count * 100)
|
|
||||||
|
|
||||||
|
|
||||||
def get_next_slot(user_id: int):
|
def get_next_slot(user_id: int):
|
||||||
query = f"SELECT slot FROM habits WHERE user_id = {user_id} ORDER BY slot DESC LIMIT 1;"
|
query = f"SELECT slot FROM habits WHERE user_id = {user_id} ORDER BY slot DESC LIMIT 1;"
|
||||||
conn = con3()
|
conn = con3()
|
||||||
@ -207,7 +187,3 @@ def delete_habitTrackings(id: int):
|
|||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
pass
|
|
||||||
Loading…
x
Reference in New Issue
Block a user