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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 101d9a1885649969932426a13aff95bcc8347df5
4
- data.tar.gz: f5129f408165c606d5dec16ce396989413575c50
3
+ metadata.gz: 464fb2b08a6a96e190e4b55e0dc6d5561a0e8ed0
4
+ data.tar.gz: 844f3059de10413a6e1c8ed81f1d950150d4500e
5
5
  SHA512:
6
- metadata.gz: d34c2766ffe545f26632485601efeed53c2a2a22cf9225387cf47f1795bd816aaeec4388f93a16fc7ece90ee6436e9c10d5582d591ea65d1ae7544ccdeb83c4f
7
- data.tar.gz: ee861a941de37ce0314e7de690359fe7b8571aedf8561994f0d3e317611e2273b00f706dbf89702561e2e57a46cc23e3c4d6868e7a6dd0fcac3f2ec954bf4f6a
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
- Rails.logger.info "GET #{request_url}"
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 "trying to import #{activity}"
24
- if !ActivityConsumer.configuration.import_types.include?(activity[:activity_type])
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
- return response.code == 304
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
- case @mode
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 request_params
60
+ def query_params
65
61
  latest = RemoteActivity.latest_timestamp
66
- latest ? "?since=#{latest}" : ""
62
+ latest ? {since: latest} : {}
67
63
  end
68
64
 
69
65
  def auth
@@ -1,3 +1,3 @@
1
1
  module ActivityConsumer
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end