5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 02:36:22 +00:00

fix: usar posts indexados para relacionar traducciones

This commit is contained in:
f 2023-10-06 17:23:55 -03:00
parent 9cb2850a13
commit ad3d52e2e7
No known key found for this signature in database

View file

@ -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