5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 02:46:21 +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] # @return [Array]
def other_locales def other_locales
site.locales.reject do |locale| @other_locales ||= site.locales.reject do |other_locale|
locale == post.lang.value.to_sym other_locale.to_s == locale
end end
end end
# Obtiene todos los posts de los otros locales con el mismo layout # Obtiene todos los posts de los otros locales con el mismo layout
# #
# @return [PostRelation] # @return [IndexedPost::ActiveRecord_AssociationRelation]
def posts def posts
other_locales.map do |locale| site.indexed_posts(locale: other_locales).where(layout: post.layout.value).where.not(post_id: post.uuid.value)
site.posts(lang: locale).where(layout: post.layout.value)
end.reduce(&:concat) || PostRelation.new(site: site, lang: 'any')
end end
end end