Class: GoogleScrapeRequestWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- GoogleScrapeRequestWorker
- Defined in:
- app/workers/google_scrape_request_worker.rb
Instance Attribute Summary collapse
-
#restaurant ⇒ Object
Returns the value of attribute restaurant.
Instance Method Summary collapse
Methods inherited from ApplicationWorker
Instance Attribute Details
#restaurant ⇒ Object
Returns the value of attribute restaurant.
5 6 7 |
# File 'app/workers/google_scrape_request_worker.rb', line 5 def restaurant @restaurant end |
Instance Method Details
#perform(restaurant_id) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/workers/google_scrape_request_worker.rb', line 7 def perform(restaurant_id) return unless Figaro.bool_env!('SIDEKIQ_ASK_GOOGLE_TO_SCRAPE_RESTAURANT_PAGE') self.restaurant = Restaurant.fetch(restaurant_id) return if locked? client_secrets_path = Figaro.env.GOOGLE_APPLICATION_CREDENTIALS! = Google::Auth::ServiceAccountCredentials.make_creds(json_key_io: File.open(client_secrets_path), scope: 'https://www.googleapis.com/auth/indexing') .fetch_access_token! service = Google::Apis::IndexingV3::IndexingService.new service. = url_notification_object = Google::Apis::IndexingV3::UrlNotification.new url_notification_object.url = restaurant.decorate.canonical_link url_notification_object.type = 'URL_UPDATED' service.publish_url_notification(url_notification_object) lock rescue Google::Apis::RateLimitError lock true end |