Fix crash on duplicate repetition import
This commit is contained in:
parent
c41a492b07
commit
49fdf47657
2 changed files with 10 additions and 2 deletions
|
@ -7,10 +7,16 @@ and this project tries to adhere to [Semantic Versioning](https://semver.org/spe
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
* 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
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Fix repetition import failing on duplicates. Will not import duplicate timestamps.
|
||||||
|
|
||||||
## [0.2.1] - 2021-08-28
|
## [0.2.1] - 2021-08-28
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -6,13 +6,15 @@ def migrate(db, habitlist, events):
|
||||||
for event in events:
|
for event in events:
|
||||||
text = event["note"]
|
text = event["note"]
|
||||||
for habit in habitlist:
|
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"])])
|
c.execute("select id from Habits where uuid = ?", [(habit["uuid"])])
|
||||||
id = c.fetchone()[0]
|
id = c.fetchone()[0]
|
||||||
print(f"found: {habit['name']} in {text}")
|
print(f"register: {habit['name']} in {text} at {event['end']}")
|
||||||
try:
|
try:
|
||||||
add_repetition(c, id, event["end"])
|
add_repetition(c, id, event["end"])
|
||||||
except sqlite3.IntegrityError:
|
except sqlite3.IntegrityError:
|
||||||
|
print("fail to register: not unique")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue