rails_url_shortener 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/jobs/rails_url_shortener/ip_crawler_job.rb +10 -6
- data/lib/rails_url_shortener/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b57e818e54f05c9209a2534ec6e76d551252a6595a8e1f81354752d46cb4fcb
|
4
|
+
data.tar.gz: 9da77343ba94664263e077045f4cf42bbace11ca49a6c010a7267e0b48fc5ccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b359b19b5d04a080f1081057b2fe90995a485ce537e33a5a543b71e2e01d8ebe3a2ac606bf6009927ec1a7d37db58c21631e3fd51206e0cacedde771f7bdbd
|
7
|
+
data.tar.gz: 72b1c6b431acc29a3050a25f0db5be0e651756c6e923027b708be1440cfc7dc335b0bd0ee3a5cf2dcaf19904c02e99e6723aaa0fb106bb56daae29f418a5ead6
|
@@ -11,12 +11,16 @@ module RailsUrlShortener
|
|
11
11
|
# create or update an existing record information for an ip
|
12
12
|
|
13
13
|
def perform(visit)
|
14
|
-
if Ipgeo.exists?(ip: visit.ip)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
if Ipgeo.exists?(ip: visit.ip)
|
15
|
+
ipgeo = Ipgeo.find_by(ip: visit.ip)
|
16
|
+
if Ipgeo.find_by(ip: visit.ip).updated_at <= Time.now - 3.months
|
17
|
+
# Then update
|
18
|
+
ip = HTTP.get("http://ip-api.com/json/#{visit.ip}?fields=status,message,country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,mobile,proxy,hosting,query")
|
19
|
+
if ip.code == 200
|
20
|
+
ipgeo.update(JSON.parse(ip.body).transform_keys { |key| key.to_s.underscore }.slice(*Ipgeo.column_names))
|
21
|
+
visit.update(ipgeo: ipgeo)
|
22
|
+
end
|
23
|
+
else
|
20
24
|
visit.update(ipgeo: ipgeo)
|
21
25
|
end
|
22
26
|
elsif !Ipgeo.exists?(ip: visit.ip)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_url_shortener
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a-chacon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -101,9 +101,9 @@ licenses:
|
|
101
101
|
- GPL-3.0
|
102
102
|
metadata:
|
103
103
|
bug_tracker_uri: https://www.github.com/a-chacon/rails-url-shortener/issues
|
104
|
-
changelog_uri: https://www.github.com/a-chacon/rails-url-shortener/releases/tag/v0.2.
|
104
|
+
changelog_uri: https://www.github.com/a-chacon/rails-url-shortener/releases/tag/v0.2.3
|
105
105
|
documentation_uri: https://github.com/a-chacon/rails-url-shortener/blob/main/README.md
|
106
|
-
source_code_uri: https://github.com/a-chacon/rails-url-shortener/tree/v0.2.
|
106
|
+
source_code_uri: https://github.com/a-chacon/rails-url-shortener/tree/v0.2.3
|
107
107
|
rubygems_mfa_required: 'true'
|
108
108
|
post_install_message:
|
109
109
|
rdoc_options: []
|