rnnr 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rnnr/version.rb +1 -1
- data/lib/send.rb +14 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96284545a44db53cd4797b2dce9afca289a26fa8
|
4
|
+
data.tar.gz: 1abaeacb99c553b8a6e2a2e622bcc0975f5ad161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07930a270d1ed857ac90e1d4f4a50fa5ab6a65a0d41dfb55a6ee7b55e3ba4083cb045263ef5b7907ca394e30e3dd311e2129c34d5d00a6deb622c77577370ba1
|
7
|
+
data.tar.gz: 260f08182afdf50bbb51ea230844a917903f4f80fca68316b86df0c3f9370983891a37d7894413612a3ade96e2c4b228fb1a9031ec2320835c2885631ace083a
|
data/lib/rnnr/version.rb
CHANGED
data/lib/send.rb
CHANGED
@@ -14,6 +14,7 @@ module Rnnr
|
|
14
14
|
today = DateTime.now
|
15
15
|
today_start = DateTime.new(today.year, today.month, today.day)
|
16
16
|
last_sunday = today_start - today_start.wday
|
17
|
+
month_ref = today_start - today_start.mday + 1
|
17
18
|
|
18
19
|
conn = Faraday.new(:url => 'https://api.ua.com')
|
19
20
|
resp = conn.get do |req|
|
@@ -29,6 +30,7 @@ module Rnnr
|
|
29
30
|
body = JSON.parse(resp.body)
|
30
31
|
yearly_distance = 0.0
|
31
32
|
weekly_distance = 0.0
|
33
|
+
monthly_distance = 0.0
|
32
34
|
body['_embedded']['workouts'].each do |workout|
|
33
35
|
yearly_distance += workout['aggregates']['distance_total']
|
34
36
|
|
@@ -36,14 +38,24 @@ module Rnnr
|
|
36
38
|
if date > last_sunday
|
37
39
|
weekly_distance += workout['aggregates']['distance_total']
|
38
40
|
end
|
41
|
+
|
42
|
+
if date > month_ref
|
43
|
+
monthly_distance += workout['aggregates']['distance_total']
|
44
|
+
end
|
39
45
|
end
|
40
46
|
yearly_distance = yearly_distance.to_miles.round(2)
|
41
47
|
weekly_distance = weekly_distance.to_miles.round(2)
|
42
|
-
|
48
|
+
monthly_distance = monthly_distance.to_miles.round(2)
|
49
|
+
yearly_milesperday = (yearly_distance / (Date.today.yday - options.offset)).round(2)
|
50
|
+
weekly_milesperday = (weekly_distance / (Date.today.wday - options.offset)).round(2)
|
51
|
+
monthly_milesperday = (monthly_distance / (Date.today.mday - options.offset)).round(2)
|
43
52
|
|
44
53
|
rslt_str = "Yearly: #{yearly_distance}"\
|
54
|
+
"\nMonthly: #{monthly_distance}"\
|
45
55
|
"\nWeekly: #{weekly_distance}"\
|
46
|
-
"\
|
56
|
+
"\nYearly Avg Miles/Day: #{yearly_milesperday}"\
|
57
|
+
"\nMonthly Avg Miles/Day: #{monthly_milesperday}"\
|
58
|
+
"\nWeekly Avg Miles/Day: #{weekly_milesperday}"
|
47
59
|
|
48
60
|
send_email rslt_str if options.email == 'true'
|
49
61
|
puts rslt_str if options.disp == 'true'
|