git-fit 0.14.0 → 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: def93fbb1103170a99f7a1a346e419c92bb147a1a6671a1a485248229a3b6178
4
- data.tar.gz: e56db533020db64602a5b62a2d05b2d42f8e2115d0212425594136506668aac5
3
+ metadata.gz: 5d4addd08029f44a569bf1e7caebc7f890f6ef31a2acc4a0a4de7c9ff74dff4c
4
+ data.tar.gz: 3eedd8d3727f7e9bea165f347fcd30ac430b37518a1c3b36ce7a91d14d2dc15c
5
5
  SHA512:
6
- metadata.gz: 844d55ba27a60361019e1ee0a26d37d378f777ba4cdcf5b9c6d7140da99f713e0d722d4171446a8a9b846d683145437e56681a3af56a3e1521c96c39446064d0
7
- data.tar.gz: ea001dd780c5eb8134c7f0eefed75c917b05b7e63d99cf395a60f7241becde2041617821b4f319142c9e22ce534f568eaeaaab6e70b8fac04143375c582e2b06
6
+ metadata.gz: 416c3f458713d03a648d723d05b48af609f5165d9d09ae3f22646089825a2fc058974c34210f5553fe9e28ee52f108932d20a69b1bf8b8aee3fa682e45cc18ad
7
+ data.tar.gz: 6fce4b173ae5d10000a2b3e0035cb81e6c2c1c656357f4373d5532a51977acdae5610d8ecba42888fddf3f846094b6653c96ebdc438e72b23422300ec2e7592e
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitFit
4
- VERSION = '0.14.0'
4
+ VERSION = '0.14.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.14.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lax