maltese 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd87da05843c09dcf82c4402bff44c0e4ab451c9f326cc4ec1078f25cbf8328a
4
- data.tar.gz: c37343dda36c0b1753da3739749ada24012e7a0c3f8288a63c65857acfaf2bf2
3
+ metadata.gz: 0d1525824890a2cf88d5783a644dc1583b912c1e32652b4913b2bf0a0ead0615
4
+ data.tar.gz: 6e405e2b5b87c89bb72fd753626862cf53b18dbd80a7e1ac0064aa3f23054ac0
5
5
  SHA512:
6
- metadata.gz: 19fb83f8685ceaa291f361956ad1a5f2b562951e007566be4f188bd8ec55855b3bf017cda37e74539b11c99f8267fe00c2c4e72591673fd9e68691089ed60a5e
7
- data.tar.gz: 10d69e6e58de77391ac05ac271ebeeeeb8c337b2f37649f9e8ad51fbc36422342bcef5e9fa64847ef89d5bf67498496cfc85171d5fbbc037d2584f9827139c7a
6
+ metadata.gz: 9056e4c7fee423af0a7c224680bc5178e87e5410491e088271084e68fccb29fd7ff11be2de51e6ab77e2cb7d4dbf0cb3327fc6ed53bf5489bf6bdc80c1e44b41
7
+ data.tar.gz: ee6b63a455a0914eb90754e48721801c9bc7a61a2dc85cffd2b1b0649ced391ee20ec24d03a493bde25deb9f47e6891c9882c43dd9f8ed014049dc972e690813
data/Dockerfile CHANGED
@@ -11,6 +11,6 @@ RUN apt-get update && apt-get upgrade -y -o Dpkg::Options::="--force-confold" &&
11
11
  apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
12
12
 
13
13
  # Install maltese gem
14
- RUN /sbin/setuser app gem install maltese -v 0.9.7
14
+ RUN /sbin/setuser app gem install maltese -v 0.9.8
15
15
 
16
16
  CMD maltese sitemap --sitemap_bucket $SITEMAP_BUCKET --rack_env $RACK_ENV --access_key $AWS_ACCESS_KEY_ID --secret_key $AWS_SECRET_ACCESS_KEY --region $AWS_REGION --slack_webhook_url $SLACK_WEBHOOK_URL
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maltese (0.9.7)
4
+ maltese (0.9.8)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  aws-sdk-s3 (~> 1.19)
7
7
  dotenv (~> 2.1, >= 2.1.1)
@@ -25,7 +25,7 @@ GEM
25
25
  addressable (2.7.0)
26
26
  public_suffix (>= 2.0.2, < 5.0)
27
27
  aws-eventstream (1.0.3)
28
- aws-partitions (1.253.0)
28
+ aws-partitions (1.254.0)
29
29
  aws-sdk-core (3.85.1)
30
30
  aws-eventstream (~> 1.0, >= 1.0.2)
31
31
  aws-partitions (~> 1, >= 1.239.0)
@@ -115,7 +115,6 @@ module Maltese
115
115
  def process_data(options = {})
116
116
  options[:start_time] = Time.now
117
117
  link_count = 0
118
- error_count = 0
119
118
 
120
119
  # walk through paginated results
121
120
  while options[:url] do
@@ -141,12 +140,10 @@ module Maltese
141
140
  else
142
141
  logger.error "An error occured for URL #{options[:url]}."
143
142
  logger.error "Error: #{response.body.fetch("errors").inspect}" if response.body.fetch("errors", nil).present?
144
- error_count += 1
145
143
  options[:url] = nil
146
144
  end
147
145
  rescue => exception
148
146
  logger.error "Error: #{exception.message}"
149
- error_count += 1
150
147
  fields = [
151
148
  { title: "Error", value: exception.message },
152
149
  { title: "Number of DOIs", value: sitemap.sitemap_index.total_link_count.to_s(:delimited), short: true },
@@ -202,12 +199,12 @@ module Maltese
202
199
  }.compact
203
200
 
204
201
  begin
205
- notifier = Slack::Notifier.new slack_webhook_url,
206
- username: "Fabrica",
207
- icon_url: SLACK_ICON_URL
202
+ notifier = Slack::Notifier.new(slack_webhook_url,
203
+ username: "Fabrica",
204
+ icon_url: SLACK_ICON_URL)
208
205
  response = notifier.ping attachments: [attachment]
209
206
  response.first.body
210
- rescue Slack::Notifier::APIError => exception
207
+ rescue => exception
211
208
  logger.error exception.message
212
209
  end
213
210
  end
@@ -1,3 +1,3 @@
1
1
  module Maltese
2
- VERSION = "0.9.7"
2
+ VERSION = "0.9.8"
3
3
  end
@@ -0,0 +1,58 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<SLACK_WEBHOOK_URL>"
6
+ body:
7
+ encoding: US-ASCII
8
+ string: payload=%7B%22username%22%3A%22Fabrica%22%2C%22icon_url%22%3A%22https%3A%2F%2Fgithub.com%2Fdatacite%2Fsegugio%2Fblob%2Fmaster%2Fsource%2Fimages%2Ffabrica.png%22%2C%22attachments%22%3A%5B%7B%22title%22%3A%22DataCite+Fabrica+Test%3A+Sitemaps+Not+Updated%22%2C%22color%22%3A%22danger%22%2C%22fields%22%3A%5B%7B%22title%22%3A%22Error%22%2C%22value%22%3A%22Error%3A+A+bad+gateway+error+occured+for+URL+https%3A%2F%2Fapi.datacite.org%2Fdois%3Fpage%255Bscroll%255D%3D7m%5Cu0026page%255Bsize%255D%3D1000%5Cu0026scroll-id%3DDnF1ZXJ5VGhlbkZldGNoBQAAAAACJPb5FjI5NUhiM3dqU0JleHRSWlJGTnhYaXcAAAAAAiT2-hYyOTVIYjN3alNCZXh0UlpSRk54WGl3AAAAAAIk9vsWMjk1SGIzd2pTQmV4dFJaUkZOeFhpdwAAAAACJPb8FjI5NUhiM3dqU0JleHRSWlJGTnhYaXcAAAAAAiT2_RYyOTVIYjN3alNCZXh0UlpSRk54WGl3.%22%7D%2C%7B%22title%22%3A%22Number+of+DOIs%22%2C%22value%22%3A%22141%2C572%22%2C%22short%22%3Atrue%7D%2C%7B%22title%22%3A%22Number+of+Sitemaps%22%2C%22value%22%3A%223%22%2C%22short%22%3Atrue%7D%2C%7B%22title%22%3A%22Time+Taken%22%2C%22value%22%3A%2217+min%22%2C%22short%22%3Atrue%7D%5D%7D%5D%7D
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - text/html
25
+ Content-Length:
26
+ - '22'
27
+ Connection:
28
+ - keep-alive
29
+ Date:
30
+ - Fri, 13 Dec 2019 08:57:43 GMT
31
+ Server:
32
+ - Apache
33
+ Vary:
34
+ - Accept-Encoding
35
+ Strict-Transport-Security:
36
+ - max-age=31536000; includeSubDomains; preload
37
+ Referrer-Policy:
38
+ - no-referrer
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ Access-Control-Allow-Origin:
42
+ - "*"
43
+ X-Via:
44
+ - haproxy-www-v6ip
45
+ X-Cache:
46
+ - Miss from cloudfront
47
+ Via:
48
+ - 1.1 df38bb2685583a05a05461e9dbcff65d.cloudfront.net (CloudFront)
49
+ X-Amz-Cf-Pop:
50
+ - MAN50-C1
51
+ X-Amz-Cf-Id:
52
+ - qCYumwTrzsq02_b9c1ZbCmluNSOrd6KyiQsfnenvF4r2TEcXj-ruWQ==
53
+ body:
54
+ encoding: ASCII-8BIT
55
+ string: ok
56
+ http_version:
57
+ recorded_at: Fri, 13 Dec 2019 08:57:43 GMT
58
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,58 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<SLACK_WEBHOOK_URL>"
6
+ body:
7
+ encoding: US-ASCII
8
+ string: payload=%7B%22username%22%3A%22Fabrica%22%2C%22icon_url%22%3A%22https%3A%2F%2Fgithub.com%2Fdatacite%2Fsegugio%2Fblob%2Fmaster%2Fsource%2Fimages%2Ffabrica.png%22%2C%22attachments%22%3A%5B%7B%22title%22%3A%22DataCite+Fabrica+Test%3A+Sitemaps+Updated%22%2C%22color%22%3A%22good%22%2C%22fields%22%3A%5B%7B%22title%22%3A%22URL%22%2C%22value%22%3A%22https%3A%2F%2Fsearch.test.datacite.org%2Fsitemaps%2Fsitemap.xml.gz%22%7D%2C%7B%22title%22%3A%22Number+of+DOIs%22%2C%22value%22%3A%22271%2C605%22%2C%22short%22%3Atrue%7D%2C%7B%22title%22%3A%22Number+of+Sitemaps%22%2C%22value%22%3A%226%22%2C%22short%22%3Atrue%7D%2C%7B%22title%22%3A%22Time+Taken%22%2C%22value%22%3A%2233+min%22%2C%22short%22%3Atrue%7D%5D%7D%5D%7D
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - text/html
25
+ Content-Length:
26
+ - '22'
27
+ Connection:
28
+ - keep-alive
29
+ Date:
30
+ - Fri, 13 Dec 2019 08:53:10 GMT
31
+ Server:
32
+ - Apache
33
+ Vary:
34
+ - Accept-Encoding
35
+ Strict-Transport-Security:
36
+ - max-age=31536000; includeSubDomains; preload
37
+ Referrer-Policy:
38
+ - no-referrer
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ Access-Control-Allow-Origin:
42
+ - "*"
43
+ X-Via:
44
+ - haproxy-www-67jr
45
+ X-Cache:
46
+ - Miss from cloudfront
47
+ Via:
48
+ - 1.1 e05f0ff5c1cc82faec67b7a1bf62aedb.cloudfront.net (CloudFront)
49
+ X-Amz-Cf-Pop:
50
+ - MAD51-C1
51
+ X-Amz-Cf-Id:
52
+ - mWI0IuqEsQvmiAy2C0KyOpDW_PgVKm0w9G91v80N_omXTNSsTxxR3A==
53
+ body:
54
+ encoding: ASCII-8BIT
55
+ string: ok
56
+ http_version:
57
+ recorded_at: Fri, 13 Dec 2019 08:53:11 GMT
58
+ recorded_with: VCR 3.0.3
@@ -103,4 +103,26 @@ describe Maltese::Sitemap, vcr: true do
103
103
  expect { subject.push_data }.to output(/1001 links/).to_stdout
104
104
  end
105
105
  end
106
+
107
+ context "send_notification_to_slack" do
108
+ it "send info" do
109
+ fields = [
110
+ { title: "URL", value: "https://search.test.datacite.org/sitemaps/sitemap.xml.gz" },
111
+ { title: "Number of DOIs", value: 271605.to_s(:delimited), short: true },
112
+ { title: "Number of Sitemaps", value: 6.to_s(:delimited), short: true },
113
+ { title: "Time Taken", value: "33 min", short: true }
114
+ ]
115
+ expect(subject.send_notification_to_slack(nil, title: subject.slack_title + ": Sitemaps Updated", level: "good", fields: fields)).to eq("ok")
116
+ end
117
+
118
+ it "send error" do
119
+ fields = [
120
+ { title: "Error", value: "Error: A bad gateway error occured for URL https://api.datacite.org/dois?page%5Bscroll%5D=7m&page%5Bsize%5D=1000&scroll-id=DnF1ZXJ5VGhlbkZldGNoBQAAAAACJPb5FjI5NUhiM3dqU0JleHRSWlJGTnhYaXcAAAAAAiT2-hYyOTVIYjN3alNCZXh0UlpSRk54WGl3AAAAAAIk9vsWMjk1SGIzd2pTQmV4dFJaUkZOeFhpdwAAAAACJPb8FjI5NUhiM3dqU0JleHRSWlJGTnhYaXcAAAAAAiT2_RYyOTVIYjN3alNCZXh0UlpSRk54WGl3." },
121
+ { title: "Number of DOIs", value: 141572.to_s(:delimited), short: true },
122
+ { title: "Number of Sitemaps", value: 3.to_s(:delimited), short: true },
123
+ { title: "Time Taken", value: "17 min", short: true }
124
+ ]
125
+ expect(subject.send_notification_to_slack(nil, title: subject.slack_title + ": Sitemaps Not Updated", level: "danger", fields: fields)).to eq("ok")
126
+ end
127
+ end
106
128
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maltese
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-12 00:00:00.000000000 Z
11
+ date: 2019-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma
@@ -343,6 +343,8 @@ files:
343
343
  - spec/fixtures/vcr_cassettes/Maltese_Sitemap/push_data/should_report_if_there_are_no_works_returned_by_the_Datacite_REST_API.yml
344
344
  - spec/fixtures/vcr_cassettes/Maltese_Sitemap/push_data/should_report_if_there_are_works_returned_by_the_Datacite_REST_API.yml
345
345
  - spec/fixtures/vcr_cassettes/Maltese_Sitemap/queue_jobs/should_report_if_there_are_works_returned_by_the_Datacite_REST_API.yml
346
+ - spec/fixtures/vcr_cassettes/Maltese_Sitemap/send_notification_to_slack/send_error.yml
347
+ - spec/fixtures/vcr_cassettes/Maltese_Sitemap/send_notification_to_slack/send_info.yml
346
348
  - spec/sitemap_spec.rb
347
349
  - spec/spec_helper.rb
348
350
  homepage: https://github.com/datacite/maltese