activity_consumer 0.5.2 → 0.5.3
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/app/services/activity_consumer/remote_activity_rest_client.rb +11 -15
- data/lib/activity_consumer/version.rb +1 -1
- data/spec/dummy/log/test.log +1643 -0
- data/spec/fixtures/vcr_cassettes/activities-delta.yml +1 -1
- data/spec/services/activity_consumer/remote_activity_rest_client_spec.rb +3 -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: 464fb2b08a6a96e190e4b55e0dc6d5561a0e8ed0
|
4
|
+
data.tar.gz: 844f3059de10413a6e1c8ed81f1d950150d4500e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 808d17c633cac10d8b19e19179fb26cc84008dd2d74b5fd0758b2e2700d1478fdf239c336475c89aeb5f0712b7b59d82500ce2fe92b978a4741856adcb7a79e0
|
7
|
+
data.tar.gz: 8b016fe91b3df519095b4605b4144e4a06ead7c52f7a70791b63d99ac3b13981f59d301009f9287421f338de1136ebe8f5f94a11652a102996e1b4a734993091
|
@@ -5,24 +5,23 @@ module ActivityConsumer
|
|
5
5
|
class RemoteActivityRestClient
|
6
6
|
include HTTParty
|
7
7
|
attr_reader :latest_etag
|
8
|
+
logger Rails.logger, :info, :curl
|
8
9
|
|
9
10
|
def initialize(mode = :delta)
|
10
11
|
@mode = mode
|
11
12
|
end
|
12
13
|
|
13
14
|
def fetch
|
14
|
-
|
15
|
-
response = self.class.get(request_url, basic_auth: auth)
|
16
|
-
Rails.logger.info "Response: #{response}"
|
15
|
+
response = self.class.get(request_url, basic_auth: auth, query: query_params)
|
17
16
|
if response.success?
|
18
17
|
@latest_etag = response.headers['ETag']
|
19
18
|
activities = []
|
20
19
|
response['activities'].each do |activity|
|
21
20
|
activity = activity.deep_symbolize_keys
|
22
21
|
|
23
|
-
Rails.logger.info "
|
24
|
-
|
25
|
-
Rails.logger.info "type not in: #{ActivityConsumer.configuration.import_types} ... skipping!"
|
22
|
+
Rails.logger.info "[ActivityConsumer] Trying to import #{activity}"
|
23
|
+
unless ActivityConsumer.configuration.import_types.include?(activity[:activity_type])
|
24
|
+
Rails.logger.info "[ActivityConsumer] type not in: #{ActivityConsumer.configuration.import_types} ... skipping!"
|
26
25
|
next
|
27
26
|
end
|
28
27
|
|
@@ -39,11 +38,9 @@ module ActivityConsumer
|
|
39
38
|
def is_fresh?
|
40
39
|
url = ActivityConsumer.configuration.activity_uri
|
41
40
|
etag = RemoteActivity.last ? RemoteActivity.last.etag : ''
|
42
|
-
Rails.logger.info "HEAD #{url} with ETag #{etag}"
|
43
41
|
response = self.class.head(url, basic_auth: auth, headers: {"If-None-Match" => etag})
|
44
|
-
Rails.logger.info "Response code: #{response.code}"
|
45
42
|
|
46
|
-
|
43
|
+
response.code == 304
|
47
44
|
end
|
48
45
|
|
49
46
|
private
|
@@ -53,17 +50,16 @@ module ActivityConsumer
|
|
53
50
|
end
|
54
51
|
|
55
52
|
def request_url
|
56
|
-
|
57
|
-
when :delta
|
58
|
-
ActivityConsumer.configuration.activity_uri + request_params
|
59
|
-
when :initial
|
53
|
+
if @mode == :initial
|
60
54
|
ActivityConsumer.configuration.activity_fullexport_uri
|
55
|
+
else
|
56
|
+
ActivityConsumer.configuration.activity_uri
|
61
57
|
end
|
62
58
|
end
|
63
59
|
|
64
|
-
def
|
60
|
+
def query_params
|
65
61
|
latest = RemoteActivity.latest_timestamp
|
66
|
-
latest ?
|
62
|
+
latest ? {since: latest} : {}
|
67
63
|
end
|
68
64
|
|
69
65
|
def auth
|