From 4872ddd227044d48efa0a2a8127ac3cbc14cdf92 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 2 Feb 2024 12:44:38 -0300 Subject: [PATCH] refactor: no es necesario buscar en un array --- app/models/site/index.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/site/index.rb b/app/models/site/index.rb index 9844c822..71c442c1 100644 --- a/app/models/site/index.rb +++ b/app/models/site/index.rb @@ -11,7 +11,6 @@ class Site has_many :indexed_posts, dependent: :destroy MODIFIED_STATUSES = %i[added modified renamed].freeze - DELETED_STATUSES = %i[deleted].freeze LOCALE_FROM_PATH = /\A_/.freeze def blob_service @@ -71,7 +70,7 @@ class Site # Obtiene todos los archivos a reindexar # - # @return [Array] + # @return [Array] def indexable_posts @indexable_posts ||= diff_with_head.each_delta.select do |delta| @@ -84,9 +83,7 @@ class Site # Elimina los artículos eliminados o que cambiaron de ubicación # del índice def remove_deleted_posts! - indexable_posts.select do |delta| - DELETED_STATUSES.include? delta.status - end.each do |delta| + indexable_posts.select(&:deleted?).each do |delta| locale, path = locale_and_path_from(delta.old_file[:path]) indexed_posts.destroy_by(locale: locale, path: path).tap do |destroyed_posts|