From 39ea2d25fc34674d566f4a5de63be39adc24cc20 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 26 Oct 2023 18:12:30 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20garantizar=20que=20el=20sitio=20est?= =?UTF-8?q?=C3=A1=20indexado=20antes=20de=20verlo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 4 +++- app/models/post/indexable.rb | 3 --- app/services/site_service.rb | 9 ++------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2746ab10..218e1e55 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -96,7 +96,9 @@ class ApplicationController < ActionController::Base end def site - @site ||= find_site + @site ||= find_site.tap do |s| + s.reindex_changes! + end end protected diff --git a/app/models/post/indexable.rb b/app/models/post/indexable.rb index 40be9b1c..38a98c2b 100644 --- a/app/models/post/indexable.rb +++ b/app/models/post/indexable.rb @@ -6,9 +6,6 @@ class Post extend ActiveSupport::Concern included do - # Indexa o reindexa el Post - after_save :index! - after_destroy :remove_from_index! # @return [IndexedPost,nil] def indexed_post diff --git a/app/services/site_service.rb b/app/services/site_service.rb index 010558d6..9301e3da 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -76,16 +76,11 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do commit_config(action: :tor) end - # Trae cambios desde la rama remota y reindexa los artículos. + # Trae cambios desde la rama remota # # @return [Boolean] def merge - result = site.repository.merge(usuarie) - - # TODO: Implementar callbacks - site.try(:index_posts!) if result - - result.present? + site.repository.merge(usuarie).present? end private