git-fit 0.13.1 → 0.14.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: 982b74047f07432a6d3383f54f53b9d585d459465140d7a35fd52dbc23589372
4
- data.tar.gz: a8ee0897607fdf8b1f6951e4f601d423f15dcfdbdcbed4b928be8d04ffc4d893
3
+ metadata.gz: 5d4addd08029f44a569bf1e7caebc7f890f6ef31a2acc4a0a4de7c9ff74dff4c
4
+ data.tar.gz: 3eedd8d3727f7e9bea165f347fcd30ac430b37518a1c3b36ce7a91d14d2dc15c
5
5
  SHA512:
6
- metadata.gz: 1fc55f0b434a310a583ff62c39c27927ed2f82c65c1f6f5e646a6b605b85f559cdf01177d7fe9dbcd35b98e2b5d3cda7456b4adb1f4a3427b59d6a22c7d64dc8
7
- data.tar.gz: 99cde1f2fac8ab122f76405686e04da91a93c404bc41667b8368371bf8c23724deba5adf669aa4cb569d451b3403e0fabd3a009b06cabd63651b6c76e90daeb5
6
+ metadata.gz: 416c3f458713d03a648d723d05b48af609f5165d9d09ae3f22646089825a2fc058974c34210f5553fe9e28ee52f108932d20a69b1bf8b8aee3fa682e45cc18ad
7
+ data.tar.gz: 6fce4b173ae5d10000a2b3e0035cb81e6c2c1c656357f4373d5532a51977acdae5610d8ecba42888fddf3f846094b6653c96ebdc438e72b23422300ec2e7592e
@@ -0,0 +1,19 @@
1
+ Sequel.migration do
2
+ up do
3
+ alter_table(:activities) do
4
+ add_column :elevation_loss, Float
5
+ add_column :elevation_min, Float
6
+ add_column :elevation_max, Float
7
+ add_column :steps, Integer
8
+ end
9
+ end
10
+
11
+ down do
12
+ alter_table(:activities) do
13
+ drop_column :steps
14
+ drop_column :elevation_max
15
+ drop_column :elevation_min
16
+ drop_column :elevation_loss
17
+ end
18
+ end
19
+ end
data/lib/git-fit.rb CHANGED
@@ -33,6 +33,7 @@ module GitFit
33
33
  average_heartrate: a[:average_heartrate],
34
34
  average_speed: a[:average_speed],
35
35
  elevation_gain: a[:elevation_gain],
36
+ elevation_loss: a[:elevation_loss],
36
37
  }
37
38
  end
38
39
 
@@ -10,7 +10,7 @@ module GitFit
10
10
  class StravaCLI < Thor
11
11
  VALID_FORMATS = %w[original tcx gpx].freeze
12
12
 
13
- TOKEN_HELP = <<~HELP
13
+ TOKEN_HELP = <<~HELP.freeze
14
14
  Token expired or invalid — generate a fresh one:
15
15
  1. Open https://www.strava.com/login and sign in (email + OTP)
16
16
  2. F12 → Application → Cookies → https://www.strava.com
@@ -17,6 +17,10 @@ module GitFit
17
17
  max_cadence: :non_null,
18
18
  summary_polyline: :best_polyline,
19
19
  elevation_gain: :median,
20
+ elevation_loss: :median,
21
+ elevation_min: :min,
22
+ elevation_max: :max,
23
+ steps: :median,
20
24
  calories: :median,
21
25
  average_temperature: :non_null,
22
26
  average_speed: :computed,
@@ -36,6 +36,8 @@ module GitFit
36
36
  total_dist = 0.0
37
37
  total_time = 0
38
38
  total_elev = 0.0
39
+ total_loss = 0.0
40
+ total_steps = 0
39
41
  breakdown = Hash.new { |h, k| h[k] = { count: 0, distance_km: 0.0, moving_time_h: 0.0 } }
40
42
 
41
43
  rows.each do |r|
@@ -43,10 +45,14 @@ module GitFit
43
45
  d = r[:distance] || 0
44
46
  t = r[:moving_time] || 0
45
47
  e = r[:elevation_gain] || 0
48
+ l = r[:elevation_loss] || 0
49
+ s = r[:steps] || 0
46
50
 
47
51
  total_dist += d
48
52
  total_time += t
49
53
  total_elev += e
54
+ total_loss += l
55
+ total_steps += s
50
56
 
51
57
  breakdown[cat][:count] += 1
52
58
  breakdown[cat][:distance_km] += d / 1000.0
@@ -70,6 +76,8 @@ module GitFit
70
76
  total_distance_km: total_dist / 1000.0,
71
77
  total_moving_time_h: total_time / 3600.0,
72
78
  total_elevation_gain_m: total_elev,
79
+ total_elevation_loss_m: total_loss,
80
+ total_steps: total_steps,
73
81
  avg_cadence: cadences.any? ? (cadences.sum / cadences.size).round(1) : nil,
74
82
  avg_power: powers.any? ? (powers.sum / powers.size).round(1) : nil,
75
83
  sport_breakdown: breakdown.sort_by { |_, v| -v[:count] }.map do |cat, v|
@@ -83,6 +91,7 @@ module GitFit
83
91
  monthly = Hash.new do |h, k|
84
92
  h[k] = { count: 0, distance_km: 0.0, moving_time_h: 0.0,
85
93
  total_hr: 0.0, hr_count: 0, total_elev: 0.0,
94
+ total_loss: 0.0, total_steps: 0,
86
95
  total_cadence: 0.0, cadence_count: 0,
87
96
  total_power: 0.0, power_count: 0 }
88
97
  end
@@ -95,11 +104,15 @@ module GitFit
95
104
  t = r[:moving_time] || 0
96
105
  hr = r[:average_heartrate]
97
106
  e = r[:elevation_gain] || 0
107
+ l = r[:elevation_loss] || 0
108
+ s = r[:steps] || 0
98
109
 
99
110
  monthly[ym][:count] += 1
100
111
  monthly[ym][:distance_km] += d / 1000.0
101
112
  monthly[ym][:moving_time_h] += t / 3600.0
102
113
  monthly[ym][:total_elev] += e
114
+ monthly[ym][:total_loss] += l
115
+ monthly[ym][:total_steps] += s
103
116
  if hr && hr > 0
104
117
  monthly[ym][:total_hr] += hr
105
118
  monthly[ym][:hr_count] += 1
@@ -131,6 +144,8 @@ module GitFit
131
144
  avg_cadence: v[:cadence_count] > 0 ? (v[:total_cadence] / v[:cadence_count]).round(0) : nil,
132
145
  avg_power: v[:power_count] > 0 ? (v[:total_power] / v[:power_count]).round(0) : nil,
133
146
  elevation_gain_m: v[:total_elev].round(0),
147
+ elevation_loss_m: v[:total_loss].round(0),
148
+ steps: v[:total_steps],
134
149
  }
135
150
  end
136
151
  end
@@ -145,13 +160,18 @@ module GitFit
145
160
  by_year.sort.map do |year, acts|
146
161
  total_dist = acts.sum { |r| r[:distance] || 0 } / 1000.0
147
162
  total_time = acts.sum { |r| r[:moving_time] || 0 }
163
+ total_elev = acts.sum { |r| r[:elevation_gain] || 0 }
164
+ total_loss = acts.sum { |r| r[:elevation_loss] || 0 }
165
+ total_steps = acts.sum { |r| r[:steps] || 0 }
148
166
  longest = acts.map { |r| r[:distance] || 0 }.max / 1000.0
149
167
 
150
168
  streak = calculate_streak(acts)
151
169
 
152
170
  { year: year, count: acts.size, distance_km: total_dist.round(1),
153
171
  moving_time_h: (total_time / 3600.0).round(1),
154
- longest_km: longest.round(1), streak: streak }
172
+ longest_km: longest.round(1), streak: streak,
173
+ elevation_gain_m: total_elev.round(0), elevation_loss_m: total_loss.round(0),
174
+ steps: total_steps }
155
175
  end
156
176
  end
157
177
 
@@ -11,7 +11,8 @@ module GitFit
11
11
  location_country summary_polyline
12
12
  average_heartrate max_heartrate average_cadence max_cadence
13
13
  average_power max_power calories average_temperature
14
- average_speed elevation_gain source dedup_group_id
14
+ average_speed elevation_gain elevation_loss elevation_min elevation_max
15
+ steps source dedup_group_id
15
16
  ].freeze
16
17
 
17
18
  def initialize(db:, output:, activity_filter: nil)
@@ -80,6 +80,10 @@ module GitFit
80
80
  average_temperature: a[:average_temperature],
81
81
  average_speed: a[:average_speed],
82
82
  elevation_gain: a[:elevation_gain],
83
+ elevation_loss: a[:elevation_loss],
84
+ elevation_min: a[:elevation_min],
85
+ elevation_max: a[:elevation_max],
86
+ steps: a[:steps],
83
87
  source: a[:source],
84
88
  }
85
89
  if a[:divisions]
@@ -103,7 +107,8 @@ module GitFit
103
107
  result
104
108
  else
105
109
  composite = members.first&.slice(:run_id, :distance, :moving_time, :elapsed_time,
106
- :average_heartrate, :max_heartrate, :elevation_gain,
110
+ :average_heartrate, :max_heartrate, :elevation_gain, :elevation_loss,
111
+ :elevation_min, :elevation_max, :steps,
107
112
  :average_speed, :average_cadence, :max_cadence) || {}
108
113
  composite[:summary_polyline] = pick_best_polyline(group_activities)
109
114
  composite