53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
def create_habits(db, trackers):
|
|
c = db.cursor()
|
|
tracker = trackers["cigarette"]
|
|
print(tracker)
|
|
habit = (
|
|
0, # archived
|
|
11, # color (but nomie: `#369DD3`, loop `2` of available selection)
|
|
tracker["label"], # name
|
|
"smoking", # description (a little one-liner extended description)
|
|
1, # freq_den (frequency denominator, either 7 for per week or 30 for per month)
|
|
1, # freq_num (frequency numerator, how often per week/month. Has to be one for ranges afaik?)
|
|
0, # highlight (function ??)
|
|
4, # position (which vertical position on screen tracker takes. must be unique?)
|
|
0, # reminder_days (simple int, but i'm not sure how, saw 127)
|
|
0, # type (range,counter [more in nomie]; string in nomie, int in loop)
|
|
0, # target_type (??)
|
|
0.0, # target_value (??)
|
|
"c", # unit (text description of value, in nomie set values with `num` being no-value count)
|
|
"Did you smoke today?", # question (text question tracker asks)
|
|
tracker["id"], # uuid (unique id, must be unique surprisingly)
|
|
)
|
|
c.execute(
|
|
"""INSERT INTO
|
|
Habits(id, archived, color, name, description, freq_den, freq_num, highlight, position, reminder_days, type, target_type, target_value, unit, question, uuid)
|
|
VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
|
habit,
|
|
)
|
|
c.execute("""select * from Habits""")
|
|
print(c.fetchall())
|
|
|
|
c.execute(
|
|
"""
|
|
INSERT INTO
|
|
Repetitions(id, habit, timestamp, value)
|
|
VALUES (NULL, 5, 1629676800000, 2)
|
|
"""
|
|
)
|
|
c.execute(
|
|
"""
|
|
INSERT INTO
|
|
Repetitions(id, habit, timestamp, value)
|
|
VALUES (NULL, 6, 1629676800000, 2)
|
|
"""
|
|
)
|
|
|
|
|
|
# grab next tracker info
|
|
|
|
# look for unique id of next habit
|
|
# if exists skip and warn user
|
|
|
|
# insert tracker into habit table
|