Skip to content

Conversation

@marshalleq
Copy link

I apologise if this does not meet the normal quality, this is my second ever PR. It is intended to bring a missing feature but I won't be offended if you don't like it. Perhaps you will need to adjust my code and use only bits of it. Either way, I have tested it and it works for me with the three or four devices I have and I hope it will be valuable for others.

Summary
Adds a new gear type "Watch/Computer" (type 9) that automatically detects and tracks the recording device when importing activities. The system now distinguishes between equipment gear (shoes, bikes) and the recording device (watch, bike computer) that captured the activity.

Key Features
Auto-Detection & Linking

  • Automatically creates watch/computer gear entries from FIT file device info during import (bulk or gamin sync)
  • Links activities to the recording device via new computer_gear_id field (separate from equipment gear_id)
  • Garmin: Full support - identified by serial number and product ID (383 models pre-populated)
  • Suunto: Basic support - identified by model name (no serial number in FIT files)
  • Strava Sync: Not supported - Strava API doesn't provide device information as far as I have been able to tell (shame because this would be really nice)

Frontend Updates

  • Activity view now displays "Recorded with: [device name]" for linked activities
  • Gear list shows "Watch/Computer" type with correct translations
  • i18n support for all 12 languages

Database Changes (Alembic migration v0_17_0)

  • New computer_models table with 383 pre-populated Garmin device models
  • New columns on gear table: serial_number, computer_model_id
  • New computer_gear_id column on activities table

Auxiliary Scripts

  • aux_scripts/clean_duplicates.py - Cleans duplicate FIT files, moves health/monitoring files, handles JSON sidecars from Intervals.icu exports
  • aux_scripts/convert_json_to_fit.py - Converts orphaned Intervals.icu JSON files to valid FIT format for import (useful for indoor activities that Runalyzer couldn't export as FIT)

Import Flow
FIT file imported

  • Extract device info (manufacturer, product_id, serial_number)
  • Lookup/create ComputerModel (e.g., "Fenix 7X")
  • Lookup/create Gear type 9 for user
  • Create Activity with:
    • gear_id = equipment (shoes/bike from default gear or sync)
    • computer_gear_id = recording device (watch/computer)

Tested With

  • Manual FIT file import (Garmin Fenix 7X, Suunto watches)
  • Garmin Connect sync
    You have to manually extract the fit files from your downloaded archive first, put them in the bulk import folder and in the case of Garmin, find the summarizedActivities.json for activity name matching and put that there as well.

Regarding the scripts: The first script (clean_duplicates.py) runs and splits out the health data into a health folder (retained under the bulk export folder), deletes the duplicates and retains the fit files for bulk import. The other thing I noticed was that exercises taken indoors without gps co-ordinates didn't get converted to fit files by Runalyzer.com meaning this history was lost. So, there's a second script in the aux-scripts to handle this (convert_json_to_fit.py. Both of these scripts operate directly out of their respective directories i.e files are converted directly from within the ophaned folder and put back into the bulk imports folder once converted.

I hope you get some value out of this and let me know if you need anything further. If we can get this one done, perhaps we can get health import done next. ;)

Regards,

Marshalleq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant