From 595b4e489830275674e5bcf12d9ec5c6879a37fd Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 30 Aug 2021 22:56:55 +0200 Subject: [PATCH] Set range targets to half of nomie max value --- CHANGELOG.md | 1 + loop/habits.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96ab19c..af1cc16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 repetition import, translated from events * 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 diff --git a/loop/habits.py b/loop/habits.py index 5e1efbf..136671f 100644 --- a/loop/habits.py +++ b/loop/habits.py @@ -10,6 +10,9 @@ def migrate(db, trackers): return habits +NOMIE_MAX_TO_TARGET_VALUE_RATIO = 2 + + def trackers_to_habits(trackers): habits = [] for tracker_name in trackers.keys(): @@ -30,8 +33,12 @@ def trackers_to_habits(trackers): } ) if t["type"] == "range" and len(habits) > 0: - habits[-1]["type"] = "1" - habits[-1]["target_value"] = t["max"] + 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 + ) return habits