Fix habit creation

Habit creation fully works successfully for the first time with this
setup.
This commit is contained in:
Marty Oehme 2021-08-27 23:34:16 +02:00
parent 270635a17e
commit 7c606436eb
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 43 additions and 10 deletions

View file

@ -53,7 +53,6 @@ label + emoji | name
? | freq_den (frequency denominator, either 7 for per week or 30 for per month)
? | freq_num (frequency numerator, how often per week/month. Has to be one for ranges afaik?)
? | highlight (function ??)
label | name
? | position (which vertical position on screen tracker takes. must be unique?)
? | reminder_hour (simple int)
? | reminder_min (simple int)

View file

@ -1,18 +1,52 @@
def create_habits(db, trackers):
print("migrating habits, yo")
c = db.cursor()
tracker = trackers["cigarette"]
print(tracker)
# for when the execute works, can be filled in its own function
habit = (
tracker["label"],
0,
0,
tracker["id"],
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, name, position, type, uuid)
VALUES (NULL, ?, ?, ?, ?)""",
"""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