git-fit 0.26.2 → 0.26.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/git_fit/sync/garmin_base.rb +24 -8
- data/lib/git_fit/sync/igpsport.rb +18 -0
- data/lib/git_fit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3cea1445cb1e525a1be8c8b814b7b3f69a27aac4e4e42411b5eb993227fef373
|
|
4
|
+
data.tar.gz: f672f8bfbded7feb9484dc8a214b945338c1a7c3136c1e80f539afe66bb1db0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e051bd7d24a99544a65b6f537bfb5483980cc399a1977310383f5f3a6ed8c4381bfe3a6811b0de3dc359571f9128b093379b4cc8d4ad923b8252190c7a738fce
|
|
7
|
+
data.tar.gz: 493fa21dffeb7d8aed1039e3aad0eaee0c3a4c4774129fbedf4293962923fcd456715b900b21dd64e1eee8e9167660bddffc968bb99aa0d8628c637215ed4a14
|
|
@@ -160,6 +160,21 @@ module GitFit
|
|
|
160
160
|
self.class.source_prefix
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
+
# device_info messages → label of the recording device. Lookup order:
|
|
164
|
+
# GARMIN_PRODUCT_SUPPLEMENT (full display name) → garminProduct token
|
|
165
|
+
# ("Garmin Edge 540") → "Garmin <pk>" fallback (workouts#38/#59)
|
|
166
|
+
def self.device_label(infos)
|
|
167
|
+
info = infos.find { |d| d['deviceIndex'] == 'creator' } || infos.first
|
|
168
|
+
return nil unless info
|
|
169
|
+
|
|
170
|
+
supplement = GARMIN_PRODUCT_SUPPLEMENT[info['product']]
|
|
171
|
+
return supplement if supplement
|
|
172
|
+
|
|
173
|
+
return nil unless info['garminProduct']
|
|
174
|
+
|
|
175
|
+
format_garmin_device(info['garminProduct'])
|
|
176
|
+
end
|
|
177
|
+
|
|
163
178
|
def self.format_garmin_device(token)
|
|
164
179
|
# garminProduct token (e.g. "edge540") or unresolved numeric pk →
|
|
165
180
|
# human label ("Garmin Edge 540" / "Garmin 3307")
|
|
@@ -690,6 +705,11 @@ module GitFit
|
|
|
690
705
|
# Garmin FIT garminProduct token prefix → display prefix (unlisted → capitalize)
|
|
691
706
|
GARMIN_DEVICE_PREFIXES = { 'fr' => 'Forerunner', 'hrm' => 'HRM' }.freeze
|
|
692
707
|
|
|
708
|
+
# Product pk → full display name for co-branded hardware missing from the
|
|
709
|
+
# bundled garminProduct profile; no "Garmin " prefix (Cannondale wheel
|
|
710
|
+
# sensor is Garmin-made but Cannondale-branded, workouts#59)
|
|
711
|
+
GARMIN_PRODUCT_SUPPLEMENT = { 3307 => 'Cannondale Wheel Sensor' }.freeze
|
|
712
|
+
|
|
693
713
|
def raw_path(platform_id)
|
|
694
714
|
File.join(raw_dir, platform_id, 'activity.fit')
|
|
695
715
|
end
|
|
@@ -774,18 +794,14 @@ module GitFit
|
|
|
774
794
|
false
|
|
775
795
|
end
|
|
776
796
|
|
|
777
|
-
# FIT device_info
|
|
778
|
-
# product ids missing
|
|
779
|
-
#
|
|
797
|
+
# FIT device_info → recording-device label (via self.class.device_label);
|
|
798
|
+
# product ids missing everywhere fall back to "Garmin <pk>" (workouts#38
|
|
799
|
+
# — Connect deviceTypePk has no public lookup table)
|
|
780
800
|
def extract_device(activity_id)
|
|
781
801
|
fit_path = raw_path(activity_id)
|
|
782
802
|
return nil unless File.exist?(fit_path)
|
|
783
803
|
|
|
784
|
-
|
|
785
|
-
info = infos.find { |d| d['deviceIndex'] == 'creator' } || infos.first
|
|
786
|
-
return nil unless info && info['garminProduct']
|
|
787
|
-
|
|
788
|
-
self.class.format_garmin_device(info['garminProduct'])
|
|
804
|
+
self.class.device_label(FIT::Decoder.device_info(fit_path))
|
|
789
805
|
rescue StandardError => e
|
|
790
806
|
warn "Garmin: device_info decode failed for #{activity_id}: #{e.message}"
|
|
791
807
|
nil
|
|
@@ -18,6 +18,11 @@ module GitFit
|
|
|
18
18
|
|
|
19
19
|
RAW_EXT = 'fit'
|
|
20
20
|
|
|
21
|
+
# FIT product id → 码表型号名。本库观测仅 104(serialNumber 2148868369 单机);
|
|
22
|
+
# 型号名经 Strava device_name 交叉佐证:本源 85 条 ↔ strava detail.device_name
|
|
23
|
+
# 'iGPSPORT BSC100Max' 85 条完全对应(workouts#59)。
|
|
24
|
+
FIT_PRODUCT_MODELS = { 104 => 'BSC100Max' }.freeze
|
|
25
|
+
|
|
21
26
|
register_adapter
|
|
22
27
|
register_config :phone, :password
|
|
23
28
|
|
|
@@ -106,12 +111,25 @@ module GitFit
|
|
|
106
111
|
elevation_stats = elevation_stats_from_records(wgs_points, fit_path)
|
|
107
112
|
|
|
108
113
|
attrs = build_attrs(act, ride_id, polyline, sensor_summary, elevation_stats)
|
|
114
|
+
attrs[:device] = extract_device(fit_path)
|
|
109
115
|
return false unless attrs
|
|
110
116
|
|
|
111
117
|
upsert_activity(attrs)
|
|
112
118
|
attrs
|
|
113
119
|
end
|
|
114
120
|
|
|
121
|
+
# FIT device_info creator → "iGPSPORT <model>";未收录 product 返回 nil
|
|
122
|
+
# (workouts#59 — 型号名仅 Strava device_name 有)
|
|
123
|
+
def extract_device(fit_path)
|
|
124
|
+
infos = FIT::Decoder.device_info(fit_path)
|
|
125
|
+
info = infos.find { |d| d['deviceIndex'] == 'creator' } || infos.first
|
|
126
|
+
model = info && FIT_PRODUCT_MODELS[info['product']]
|
|
127
|
+
model ? "iGPSPORT #{model}" : nil
|
|
128
|
+
rescue StandardError => e
|
|
129
|
+
warn "IGPSPORT: device_info decode failed for #{fit_path}: #{e.message}"
|
|
130
|
+
nil
|
|
131
|
+
end
|
|
132
|
+
|
|
115
133
|
def get_download_url(ride_id)
|
|
116
134
|
resp = Faraday.get("#{DOWNLOAD_URL}/#{ride_id}", {}, @auth_headers)
|
|
117
135
|
return nil unless resp.status == 200
|
data/lib/git_fit/version.rb
CHANGED