From ad3d52e2e78ce58cb100728aa27b1ba6b159e7b6 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 6 Oct 2023 17:23:55 -0300 Subject: [PATCH] fix: usar posts indexados para relacionar traducciones --- app/models/metadata_locales.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/models/metadata_locales.rb b/app/models/metadata_locales.rb index 37b50286..85419da8 100644 --- a/app/models/metadata_locales.rb +++ b/app/models/metadata_locales.rb @@ -33,17 +33,15 @@ class MetadataLocales < MetadataHasAndBelongsToMany # # @return [Array] def other_locales - site.locales.reject do |locale| - locale == post.lang.value.to_sym + @other_locales ||= site.locales.reject do |other_locale| + other_locale.to_s == locale end end # Obtiene todos los posts de los otros locales con el mismo layout # - # @return [PostRelation] + # @return [IndexedPost::ActiveRecord_AssociationRelation] def posts - other_locales.map do |locale| - site.posts(lang: locale).where(layout: post.layout.value) - end.reduce(&:concat) || PostRelation.new(site: site, lang: 'any') + site.indexed_posts(locale: other_locales).where(layout: post.layout.value).where.not(post_id: post.uuid.value) end end