git-fit 0.21.0 → 0.21.1

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: e9ac100a25388c8d2e9a82f541b14b369a08f4307cfa70949032c25a8afc7c74
4
- data.tar.gz: 60eb1e4c683317df12d66260517b21db9841823b9b20de6defa2819bbecd4b65
3
+ metadata.gz: 30f139ea0a7c21e9a99189ac7541c8b80c35377f40742823843dbcd5b2ce604a
4
+ data.tar.gz: b554587d97956af6e3a532ab67b6eca755377005f82eec38c500414d7bd1c4c4
5
5
  SHA512:
6
- metadata.gz: a50e41061abe840e12c2a2f5741cef761dd97f5d87867d830bcb04e6ce7da61e8da48ff54e2500252c8c78c3f5a6a033dde69d695d49257a8d08f97c24799a02
7
- data.tar.gz: 6db8e171e162cb31c9aca678c0db13e8271f1d61d0d1bf2097f12c1189d8130861349a69991907a7f0cc36c69e36b2892db7dd6f4950b984ec3473e15e2fd5b8
6
+ metadata.gz: 5b23770d805a5c42fdbe3b4322e3557bd4938033e2e7e3094e934354d16fbc8c6bb7d7ed028ae5ffe9684b785d7e5fdca560e17480fd020713c1b96302795bb2
7
+ data.tar.gz: 32dde756e5dc46d3f859a992779187ccf2e478e9de05b681f79184ba2c35838822f29586f9d4e9c79d26e1d8d767c1771d4ed80172fa6fd21ec9ff7851345720
@@ -16,6 +16,10 @@ module GitFit
16
16
  GRID = 0.0003
17
17
 
18
18
  class << self
19
+ # OpenTopography free tier allows 1 request/second — pacing below that
20
+ # guarantees a 429 on every cold-cache slice (observed in workouts CI).
21
+ DEM_SLICE_INTERVAL = 1.05
22
+
19
23
  def model_path
20
24
  @model_path ||= find_model
21
25
  end
@@ -62,18 +66,26 @@ module GitFit
62
66
  def elevations_for(locations)
63
67
  uniq_vals = uniquify_locations(locations)
64
68
  elevs = {}
69
+ last_api = nil
65
70
  uniq_vals.each_slice(100).with_index do |slice, bi|
66
71
  cached = DemCache.load_batch(slice)
67
72
  elevs.merge!(cached)
68
73
  missing = DemCache.missing_keys(slice, cached)
69
- if missing.any?
70
- missing_locations = missing.map { |lat, lng| [lat, lng] }
71
- batch = {}
72
- DemFetch.fetch_batch(missing_locations, bi, batch, method(:grid_key))
73
- elevs.merge!(batch)
74
- DemCache.save_batch(batch)
74
+ next if missing.empty?
75
+
76
+ # Pace API→API independently of interleaved cache-hit slices:
77
+ # cache processing is free, only consecutive fetches must respect
78
+ # the provider's 1 req/s limit.
79
+ if last_api
80
+ elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - last_api
81
+ sleep(DEM_SLICE_INTERVAL - elapsed) if elapsed < DEM_SLICE_INTERVAL
75
82
  end
76
- sleep 0.15
83
+ missing_locations = missing.map { |lat, lng| [lat, lng] }
84
+ batch = {}
85
+ DemFetch.fetch_batch(missing_locations, bi, batch, method(:grid_key))
86
+ elevs.merge!(batch)
87
+ DemCache.save_batch(batch)
88
+ last_api = Process.clock_gettime(Process::CLOCK_MONOTONIC)
77
89
  end
78
90
  locations.map { |lat, lng| elevs[grid_key(lat, lng)] }
79
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitFit
4
- VERSION = '0.21.0'
4
+ VERSION = '0.21.1'
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.0
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lax