mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-26 02:26:23 +00:00
fix: usar posts indexados para relacionar traducciones
This commit is contained in:
parent
9cb2850a13
commit
ad3d52e2e7
1 changed files with 4 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue