From f28ba4095388ae965b129ac5b69c51d3c532ecca Mon Sep 17 00:00:00 2001 From: f Date: Fri, 20 Oct 2023 12:22:18 -0300 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20leer=20el=20sitio=20completo=20duran?= =?UTF-8?q?te=20la=20indexaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/site/index.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/site/index.rb b/app/models/site/index.rb index e11095e3..20914905 100644 --- a/app/models/site/index.rb +++ b/app/models/site/index.rb @@ -14,7 +14,14 @@ class Site def index_posts! Site.transaction do - docs.each(&:index!) + jekyll.read + jekyll.documents.each do |doc| + doc.read! + + Post.new(document: doc, site: self, layout: layouts[doc['layout'].to_sym).index! + end + + update(last_indexed_commit: repository.head_commit.oid) end end end From 5eafbaa5e98b66605298f4f062d3673bcc87a978 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 20 Oct 2023 12:22:47 -0300 Subject: [PATCH 2/6] fix: poder indexar desde cero --- app/models/metadata_order.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/metadata_order.rb b/app/models/metadata_order.rb index 577e3c85..f63a7d49 100644 --- a/app/models/metadata_order.rb +++ b/app/models/metadata_order.rb @@ -5,7 +5,7 @@ class MetadataOrder < MetadataTemplate # El valor según la posición del post en la relación ordenada por # fecha, a fecha más alta, posición más alta def default_value - super || (site.indexed_posts(locale: locale).first.order + 1) + super || ((site.indexed_posts.where(locale: locale).first&.order || 0) + 1) end def save From 747ce788a25f3f3e48e83287aea6351515ebe3dd Mon Sep 17 00:00:00 2001 From: f Date: Fri, 20 Oct 2023 12:23:01 -0300 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20un=20filtro=20con=20par=C3=A1metros?= =?UTF-8?q?=20vac=C3=ADos=20no=20devuelve=20una=20asociaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit en cambio where(nil) no produce ningún efecto --- app/models/metadata_related_posts.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/metadata_related_posts.rb b/app/models/metadata_related_posts.rb index 50b8660e..a9aaaa21 100644 --- a/app/models/metadata_related_posts.rb +++ b/app/models/metadata_related_posts.rb @@ -34,14 +34,14 @@ class MetadataRelatedPosts < MetadataArray # # @return [IndexedPost::ActiveRecord_AssociationRelation] def posts - site.indexed_posts.where(locale: locale).where.not(post_id: post.uuid.value).where(**filter) + site.indexed_posts.where(locale: locale).where.not(post_id: post.uuid.value).where(filter) end # Encuentra el filtro desde el esquema del atributo # - # @return [Hash] + # @return [Hash,nil] def filter - layout.metadata.dig(name, 'filter')&.to_h&.symbolize_keys || {} + layout.metadata.dig(name, 'filter')&.to_h&.symbolize_keys end def sanitize(uuid) From 40f5eca7abac7aa1a92f36373830c1f476d51431 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 20 Oct 2023 12:23:39 -0300 Subject: [PATCH 4/6] =?UTF-8?q?fix:=20algunos=20metadatos=20todav=C3=ADa?= =?UTF-8?q?=20no=20son=20indexables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/post/indexable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/post/indexable.rb b/app/models/post/indexable.rb index 9629efd0..3aa8ce59 100644 --- a/app/models/post/indexable.rb +++ b/app/models/post/indexable.rb @@ -51,7 +51,7 @@ class Post indexable_attributes.select do |attr| self[attr].front_matter? end.each do |attr| - ifm[attr] = self[attr].indexable_values + ifm[attr] = self[attr].try(:indexable_values) end end end From 8350bfdfeb971987abbf0d611f391280841bbd3f Mon Sep 17 00:00:00 2001 From: f Date: Fri, 20 Oct 2023 12:23:57 -0300 Subject: [PATCH 5/6] fix: no leer los posts al obtener relaciones --- app/views/posts/attribute_ro/_related_posts.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/posts/attribute_ro/_related_posts.haml b/app/views/posts/attribute_ro/_related_posts.haml index 6014e160..aa4aff2e 100644 --- a/app/views/posts/attribute_ro/_related_posts.haml +++ b/app/views/posts/attribute_ro/_related_posts.haml @@ -2,10 +2,9 @@ %th= post_label_t(attribute, post: post) %td %ul{ dir: dir, lang: locale } - - metadata.value.each do |v| - - p = site.indexed_posts(locale: post.lang.value).find_by(post_id: v)&.post + - site.indexed_posts.where(locale: post.lang.value, post_id: metadata.value).find_each do |p| -# XXX: Ignorar todos los posts no encontrados (ej: fueron borrados o el uuid cambió) - next unless p - %li= link_to p.title.value, site_post_path(site, p.id) + %li= link_to p.title, site_post_path(site, p.path) From 98d1ec125a8cd57df0dc7e3b415419895f343b8e Mon Sep 17 00:00:00 2001 From: f Date: Fri, 20 Oct 2023 13:10:53 -0300 Subject: [PATCH 6/6] fixup! fix: poder indexar desde cero --- app/models/site/index.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/site/index.rb b/app/models/site/index.rb index 20914905..2f2d1dc9 100644 --- a/app/models/site/index.rb +++ b/app/models/site/index.rb @@ -18,7 +18,7 @@ class Site jekyll.documents.each do |doc| doc.read! - Post.new(document: doc, site: self, layout: layouts[doc['layout'].to_sym).index! + Post.new(document: doc, site: self, layout: layouts[doc['layout'].to_sym]).index! end update(last_indexed_commit: repository.head_commit.oid)