From 1dddc0525aec1f79372d8bb6930d6cb20179f999 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 5 Feb 2024 15:23:48 +0100 Subject: [PATCH] wip --- app/controllers/admin/communication/websites_controller.rb | 2 -- app/models/communication/website/with_connected_objects.rb | 7 ++++--- app/services/screenshot.rb | 3 +++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index d674653a8..1b27bcfe1 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -59,8 +59,6 @@ class Admin::Communication::WebsitesController < Admin::Communication::Websites: def update if @website.update_and_sync(website_params) - # TODO better place, background job once w week? - @website.screenshot! redirect_to [:admin, @website], notice: t('admin.successfully_updated_html', model: @website.to_s) else breadcrumb diff --git a/app/models/communication/website/with_connected_objects.rb b/app/models/communication/website/with_connected_objects.rb index d04e87e18..62a4654e3 100644 --- a/app/models/communication/website/with_connected_objects.rb +++ b/app/models/communication/website/with_connected_objects.rb @@ -21,6 +21,7 @@ module Communication::Website::WithConnectedObjects sync_with_git_without_delay destroy_obsolete_git_files_without_delay get_current_theme_version! + screenshot! end handle_asynchronously :clean_and_rebuild, queue: :cleanup @@ -88,9 +89,9 @@ module Communication::Website::WithConnectedObjects University::Organization.where(id: ids) end - def connected_publications - ids = connections.where(indirect_object_type: 'Research::Publication').pluck(:indirect_object_id) - Research::Publication.where(id: ids) + def connected_hal_publications + ids = connections.where(indirect_object_type: 'Research::Hal::Publication').pluck(:indirect_object_id) + Research::Hal::Publication.where(id: ids) end # ensure the object "website" respond to both is_direct_object? and is_indirect_object? as website doesn't include neither as_direct_object nor as_indirect_object diff --git a/app/services/screenshot.rb b/app/services/screenshot.rb index 37934418e..156e2d599 100644 --- a/app/services/screenshot.rb +++ b/app/services/screenshot.rb @@ -23,6 +23,9 @@ class Screenshot meta: false, waitUntil: 'load', device: 'Macbook Pro 15' + }, + headers: { + x-api-key: ENV['MICROLINK_API_KEY'] } }) data = JSON.parse(response.body) -- GitLab