dont-overstay 0.0.1 → 0.0.2
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 +4 -4
- data/lib/dont-overstay.rb +8 -3
- 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: 1fecd3eca9860702512068c85514cfd5ef3b1551
|
|
4
|
+
data.tar.gz: 01bc5589303d725ad5d10199d7a8924f473a3845
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdf887195a69f0aa8a7e5f9ea2cf07075b5631a3a73002b78d77f89e66936bc69a8cf8f713a3484812b35b08f2cf1918c7be3c38b9e85e0da9a2dabce19c919e
|
|
7
|
+
data.tar.gz: 66ade12b67578345967297b8f6ae6b3a079a5f28422b887dc3ef0edea3faa0078485b597f8d539a77870bc4bcca248e9cd41958c5999845528989c4f27aa79fd
|
data/lib/dont-overstay.rb
CHANGED
|
@@ -12,7 +12,12 @@ class Daytracker
|
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def query(before=Time.now.to_i, after=
|
|
15
|
+
def query(before=Time.now.to_i, after=((Date.today - 365).to_time.to_i), padded_days=0)
|
|
16
|
+
if ENV['dryrun'] then
|
|
17
|
+
if ENV['dryrun'] == "true" then
|
|
18
|
+
return {:status => "Test", before: before, after: after, padded_days: (padded_days || 0)}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
16
21
|
country_list = []
|
|
17
22
|
if @full_url != nil then
|
|
18
23
|
if before.to_i + 3600 > Time.now.to_i then
|
|
@@ -30,7 +35,7 @@ class Daytracker
|
|
|
30
35
|
if meta["code"] == 200 then
|
|
31
36
|
checkins.each{|checkin|
|
|
32
37
|
if country_list.length == 0 then
|
|
33
|
-
country_list << {:visit => checkin["createdAt"].to_i, :code => checkin["venue"]["location"]["cc"].to_s, :name => checkin["venue"]["location"]["country"].to_s, length:
|
|
38
|
+
country_list << {:visit => checkin["createdAt"].to_i, :code => checkin["venue"]["location"]["cc"].to_s, :name => checkin["venue"]["location"]["country"].to_s, length: padded_days.to_i}
|
|
34
39
|
else
|
|
35
40
|
if country_list[country_list.length - 1][:code] == checkin["venue"]["location"]["cc"] then
|
|
36
41
|
# Work out days between the last checkin
|
|
@@ -41,7 +46,7 @@ class Daytracker
|
|
|
41
46
|
country_list[country_list.length - 1][:length] = days.to_i # Set the number of days stayed here
|
|
42
47
|
else
|
|
43
48
|
# Then just create a new entry
|
|
44
|
-
country_list << {:visit => checkin["createdAt"].to_i, :code => checkin["venue"]["location"]["cc"].to_s, :name => checkin["venue"]["location"]["country"].to_s, length:
|
|
49
|
+
country_list << {:visit => checkin["createdAt"].to_i, :code => checkin["venue"]["location"]["cc"].to_s, :name => checkin["venue"]["location"]["country"].to_s, length: padded_days.to_i}
|
|
45
50
|
end
|
|
46
51
|
end
|
|
47
52
|
after_timestamp = checkin["createdAt"].to_i + 1800 # Set the createdAt to after Timestamp
|