git-fit 0.21.3 → 0.21.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f867a5ad738983c2d5e3a10d837b3f4c0f6de6bc303d1124fdec5fccf4a8796b
4
- data.tar.gz: 50cefd5a1b88b2282396942ab3809c1a87f7ac6a6ac977c00cf77cf12a39ec04
3
+ metadata.gz: ee59f447feece2b79c93671bd58f34374178d6b7e1f17ad6444f6b1d07a906c3
4
+ data.tar.gz: 35493309be5989b82b7b27dcee0821befc8f42fe86d68c0f1304444e63461ab3
5
5
  SHA512:
6
- metadata.gz: 4390df21b2c3a0cb8167c0d5b0deb5e9fc495391fe0993104f942199249e6520d7ea8923d96f80c23683331c8ddfdff1e3e5cb47e69add1c067185290fe4befd
7
- data.tar.gz: 3bc09da8cf7493ba99b274fa2aecbbdee9843e5a2b83e8fb3d8e1ca8dfe3db4016978e240666ae13751f8fea09537b19f65fcbff7632ed4244f7b1a9aba5d56f
6
+ metadata.gz: da503a2a3edfad88f2de9dd5018be3955f254316630aa507a2a58b7c55632001c1b942422c1f306850f1792d7858298a4c0c3cfbf19bf5f8559e696480fee60c
7
+ data.tar.gz: ffa50cac4cb4ef2534408cc971c6f75bb61c4b2e921146cdf3d58e647c7e549c3e57e5e87c082f504bc9addd6b8d28878e6e0649632dfadb7b4aa4b32cd71599
@@ -3,7 +3,7 @@
3
3
  module GitFit
4
4
  module Elevation
5
5
  class Backfill
6
- SOURCES = %w[igpsport xoss strava garmin garmin_cn xingzhe].freeze
6
+ SOURCES = %w[igpsport xoss strava garmin garmin_cn xingzhe keep].freeze
7
7
  BATCH_SIZE = 100
8
8
 
9
9
  def initialize(db, force: false)
@@ -62,6 +62,7 @@ module GitFit
62
62
  when 'garmin_cn' then compute_from_fit(source, natural_id)
63
63
  when 'strava' then compute_from_l2(source, natural_id)
64
64
  when 'xingzhe' then compute_from_xingzhe(natural_id)
65
+ when 'keep' then compute_from_keep(natural_id)
65
66
  else return
66
67
  end
67
68
 
@@ -104,6 +105,38 @@ module GitFit
104
105
  nil
105
106
  end
106
107
 
108
+ def compute_from_keep(natural_id)
109
+ l2_path = File.join('data', 'std', 'keep', "#{natural_id}.json")
110
+ return nil unless File.exist?(l2_path)
111
+
112
+ l2 = JSON.parse(File.read(l2_path))
113
+ return nil unless l2.is_a?(Array)
114
+
115
+ alts = l2.filter_map do |pt|
116
+ next unless pt.is_a?(Hash)
117
+
118
+ alt = pt['altitude']
119
+ next unless alt
120
+
121
+ alt.to_f
122
+ end
123
+ return nil if alts.size < 2
124
+
125
+ gain = elevation_gain_from_alts(alts, threshold: 0.0)
126
+ loss = elevation_loss_from_alts(alts, threshold: 0.0)
127
+ filtered = self.class.filter_low_outliers(alts)
128
+
129
+ {
130
+ elevation_gain: gain.round(1),
131
+ elevation_loss: loss.round(1),
132
+ elevation_min: (filtered.min || alts.min)&.round(1),
133
+ elevation_max: alts.max&.round(1),
134
+ }
135
+ rescue StandardError => e
136
+ warn "Elevation backfill [keep][#{natural_id}]: #{e.message}"
137
+ nil
138
+ end
139
+
107
140
  def compute_from_xingzhe(natural_id)
108
141
  # New per-id directory: data/raw/xingzhe/{id}/stream.json (Phase 1, commit 661007e)
109
142
  # Legacy flat: data/raw/xingzhe/{id}.json
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitFit
4
- VERSION = '0.21.3'
4
+ VERSION = '0.21.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-fit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.3
4
+ version: 0.21.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lax