Skip to content

Commit

Permalink
Merge branch 'main' of github.com:n8henrie/healthkit-to-sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
n8henrie committed Mar 13, 2021
2 parents 27b3d54 + 455eda9 commit d2f44a3
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 @@ -61,7 +61,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 d2f44a3

Please sign in to comment.