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|