From 49fdf47657e6a6148e22e6c5b5c17aa1f1543b40 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 29 Aug 2021 09:47:27 +0200 Subject: [PATCH] Fix crash on duplicate repetition import --- CHANGELOG.md | 6 ++++++ loop/repetitions.py | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d1b3c..96ab19c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,16 @@ and this project tries to adhere to [Semantic Versioning](https://semver.org/spe ## [Unreleased] +### Added + * 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 +### Fixed + +* Fix repetition import failing on duplicates. Will not import duplicate timestamps. + ## [0.2.1] - 2021-08-28 ### Fixed diff --git a/loop/repetitions.py b/loop/repetitions.py index f7d8113..0f56d95 100644 --- a/loop/repetitions.py +++ b/loop/repetitions.py @@ -6,13 +6,15 @@ def migrate(db, habitlist, events): for event in events: text = event["note"] for habit in habitlist: - if f"#{habit['description']}" in text: + tag = f"#{habit['description']}" + if tag in text: c.execute("select id from Habits where uuid = ?", [(habit["uuid"])]) id = c.fetchone()[0] - print(f"found: {habit['name']} in {text}") + print(f"register: {habit['name']} in {text} at {event['end']}") try: add_repetition(c, id, event["end"]) except sqlite3.IntegrityError: + print("fail to register: not unique") pass