Set range targets to half of nomie max value

This commit is contained in:
Marty Oehme 2021-08-30 22:56:55 +02:00
parent 82054087f9
commit 595b4e4898
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 10 additions and 2 deletions

View file

@ -12,6 +12,7 @@ and this project tries to adhere to [Semantic Versioning](https://semver.org/spe
* Add range habits, translating nomie max value to range target in Loop * Add range habits, translating nomie max value to range target in Loop
* Add repetition import, translated from events * Add repetition import, translated from events
* Does not do ranged habits or multiple entries for simple trackers in nomie yet * Does not do ranged habits or multiple entries for simple trackers in nomie yet
* Adding ranges defaults target value to half of maximum nomie value
### Fixed ### Fixed

View file

@ -10,6 +10,9 @@ def migrate(db, trackers):
return habits return habits
NOMIE_MAX_TO_TARGET_VALUE_RATIO = 2
def trackers_to_habits(trackers): def trackers_to_habits(trackers):
habits = [] habits = []
for tracker_name in trackers.keys(): for tracker_name in trackers.keys():
@ -30,8 +33,12 @@ def trackers_to_habits(trackers):
} }
) )
if t["type"] == "range" and len(habits) > 0: if t["type"] == "range" and len(habits) > 0:
habits[-1]["type"] = "1" habits[-1]["type"] = 1
habits[-1]["target_value"] = t["max"] # 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
)
return habits return habits