Skip to content

Commit

Permalink
Add a fallback ID, print if no ID found
Browse files Browse the repository at this point in the history
  • Loading branch information
n8henrie committed Mar 13, 2021
1 parent 71e36e1 commit 455eda9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion healthkit_to_sqlite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ def workout_to_db(workout, db, zipfile=None):
record["metadata_" + el.attrib["key"]] = el.attrib["value"]
# Dump any WorkoutEvent in a nested list for the moment
record["workout_events"] = [el.attrib for el in workout.findall("WorkoutEvent")]
pk = db["workouts"].insert(record, alter=True, hash_id="id").last_pk

record_id_key = "id"
if record.get("metadata_HKExternalUUID") and not record.get("id"):
record_id_key = "metadata_HKExternalUUID"

if not record.get(record_id_key):
print(f"No ID for record: {record}")
return

pk = db["workouts"].insert(record, alter=True, hash_id=record_id_key).last_pk
# Handle embedded WorkoutRoute/Location points
points = [
# <Location
Expand Down

0 comments on commit 455eda9

Please sign in to comment.