Skip to content

Commit 634e05b

Browse files
authored
Remove facebook metrics (#467)
Remove facebook metrics Since we no longer use facebook metrics, we are removing all references to the metrics code. References: CV2-4226
1 parent 2c9150c commit 634e05b

File tree

11 files changed

+6
-448
lines changed

11 files changed

+6
-448
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ Clears the cache for the URL(s) passed as parameter.
299299

300300
## Webhook Notification
301301

302-
The metrics and archiving feature are asynchronous events. Pender can notify your application after it requests the metrics or sends the URLs for archiving.
302+
The archiving feature uses asynchronous events. Pender can notify your application after it sends URLs for archiving.
303303

304304
Pender sends the `url`, `type` and the information associated with the event. The webhook endpoint should have an associated URL (e.g., http://api:3000/api/webhooks/keep) and a token. These information should be added to API key's `application_settings`: `api_key.application_settings = {:webhook_url=>"http://api:3000/api/webhooks/keep", :webhook_token=>"somethingsecret"}`
305305

app/models/media.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
# 4. Match the url with the patterns described on specific parsers
3737
# 5. Parse the page with the parser found on previous step
3838
# 6. Archives the page in background, for the archivers that apply to the current URL
39-
# 7. Get metrics for the current URL, in background
4039
# * Parse as oEmbed
4140
# 1. Get media the json data
4241
# 2. If the page has an oEmbed url, request it and get the response
@@ -85,7 +84,6 @@ def as_json(options = {})
8584
self.upload_images
8685
end
8786
archive_if_conditions_are_met(options, id, cache)
88-
Metrics.schedule_fetching_metrics_from_facebook(self.data, self.url, ApiKey.current&.id)
8987
parser_requests_metrics
9088
cache.read(id, :json) || cleanup_data_encoding(data)
9189
end
@@ -118,7 +116,7 @@ def as_json(options = {})
118116
def self.minimal_data(instance)
119117
data = {}
120118
%w(published_at username title description picture author_url author_picture author_name screenshot external_id html).each { |field| data[field.to_sym] = ''.freeze }
121-
data[:raw] = data[:archives] = data[:metrics] = {}
119+
data[:raw] = data[:archives] = {}
122120
data.merge(Media.required_fields(instance)).with_indifferent_access
123121
end
124122

app/models/metrics.rb

Lines changed: 0 additions & 128 deletions
This file was deleted.

app/workers/metrics_worker.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

swagger/v1/swagger.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ paths:
142142
screenshot: ''
143143
external_id: ''
144144
html: ''
145-
metrics: {}
146145
archives: {}
147146
raw:
148147
metatags:

test/integration/parsers/facebook_item_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class FacebookItemIntegrationTest < ActiveSupport::TestCase
3232
assert_equal 'item', data['type']
3333
assert data['external_id'].blank?
3434
assert data['error'].nil?
35-
assert !data['raw']['crowdtangle']['error'].blank?
3635
assert !data['title'].blank?
3736
assert !data['description'].blank?
3837
assert !data['picture'].blank?
@@ -47,7 +46,6 @@ class FacebookItemIntegrationTest < ActiveSupport::TestCase
4746
assert_equal 'item', data['type']
4847
assert_equal '111111111111111_1111111111111111', data['external_id']
4948
assert_equal 'https://www.facebook.com/111111111111111/posts/1111111111111111', data['title']
50-
assert !data['raw']['crowdtangle']['error'].blank?
5149
assert_equal '', data['username']
5250
assert_equal '', data['author_name']
5351
assert_equal '', data['author_picture']

test/models/archiver_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ def setup
55
WebMock.enable!
66
WebMock.disable_net_connect!(allow: [/minio/])
77
Sidekiq::Testing.inline!
8-
Metrics.stubs(:request_metrics_from_facebook).returns({ 'share_count' => 123 })
98
clear_bucket
109
end
1110

@@ -562,7 +561,6 @@ def create_api_key_with_webhook_for_perma_cc
562561

563562
Media.any_instance.unstub(:archive_to_perma_cc)
564563
Media.stubs(:available_archivers).returns(['perma_cc'])
565-
Metrics.stubs(:schedule_fetching_metrics_from_facebook).returns(nil)
566564
WebMock.stub_request(:get, url).to_return(status: 200, body: '<html>A Page</html>')
567565
WebMock.stub_request(:post, /safebrowsing\.googleapis\.com/).to_return(status: 200, body: '{}')
568566
WebMock.stub_request(:post, "https://example.com/webhook.php").to_return(status: 200, body: '')

test/models/media_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def teardown
584584
webhook_info = { 'webhook_url' => 'http://example.com/webhook', 'webhook_token' => 'test' }
585585

586586
assert_raises Pender::Exception::RetryLater do
587-
Media.notify_webhook('metrics', 'http://example.com', {}, webhook_info)
587+
Media.notify_webhook('archive.org', 'http://example.com', {}, webhook_info)
588588
end
589589
end
590590

@@ -599,7 +599,7 @@ def teardown
599599

600600
PenderSentry.stub(:notify, arguments_checker) do
601601
assert_nothing_raised do
602-
Media.notify_webhook('metrics', 'http://example.com', {}, webhook_info)
602+
Media.notify_webhook('archive.org', 'http://example.com', {}, webhook_info)
603603
end
604604
end
605605
assert_equal 1, sentry_call_count
@@ -609,12 +609,12 @@ def teardown
609609
webhook_info = { 'webhook_url' => 'http://example.com/webhook', 'webhook_token' => 'test' }
610610

611611
WebMock.stub_request(:post, /example.com/).and_return(status: 200, body: 'fake response body')
612-
response = Media.notify_webhook('metrics', 'http://example.com', {}, webhook_info)
612+
response = Media.notify_webhook('archive.org', 'http://example.com', {}, webhook_info)
613613
assert_equal "200", response.code
614614
assert_equal 'fake response body', response.body
615615

616616
WebMock.stub_request(:post, /example.com/).and_return(status: 201, body: 'fake response body')
617-
response = Media.notify_webhook('metrics', 'http://example.com', {}, webhook_info)
617+
response = Media.notify_webhook('archive.org', 'http://example.com', {}, webhook_info)
618618
assert_equal "201", response.code
619619
assert_equal 'fake response body', response.body
620620
end

0 commit comments

Comments
 (0)