Fix import of nomie goal value
This commit is contained in:
parent
8eb9b6a492
commit
aa2aff4e17
2 changed files with 73 additions and 2 deletions
|
|
@ -1,7 +1,10 @@
|
|||
import sqlite3
|
||||
|
||||
from habitmove.nomiedata import Tracker
|
||||
from habitmove.loopdata import Habit
|
||||
|
||||
|
||||
def migrate(db, trackers):
|
||||
def migrate(db: sqlite3.Connection, trackers: list[Tracker]):
|
||||
c = db.cursor()
|
||||
habits = trackers_to_habits(trackers)
|
||||
for habit in habits:
|
||||
|
|
@ -34,7 +37,9 @@ def trackers_to_habits(trackers):
|
|||
habits[-1].type = 1
|
||||
# nomie only has concept of max value,
|
||||
# use a percentage of it for Loop range target
|
||||
habits[-1].target_value = int(t.max) // NOMIE_MAX_TO_TARGET_VALUE_RATIO
|
||||
habits[-1].target_value = (
|
||||
t.goal or int(t.max) // NOMIE_MAX_TO_TARGET_VALUE_RATIO
|
||||
)
|
||||
return habits
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue