From 189b94e074cfb63bc14408584e7098eb48149b79 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 14 May 2021 17:19:03 -0300 Subject: [PATCH] =?UTF-8?q?aplicar=20cach=C3=A9=20a=20los=20par=C3=A1metro?= =?UTF-8?q?s=20de=20b=C3=BAsqueda=20tambi=C3=A9n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/posts_controller.rb | 9 +++------ db/schema.rb | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index e1971400..3ef26720 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -20,14 +20,11 @@ class PostsController < ApplicationController def index authorize Post - @site = find_site - @locale = locale - # XXX: Cada vez que cambiamos un Post tocamos el sitio con lo que es # más simple saber si hubo cambios. - if filter_params.present? || stale?([current_usuarie, @site]) + if stale?([current_usuarie, site, filter_params]) # Todos los artículos de este sitio para el idioma actual - @posts = @site.indexed_posts.where(locale: locale) + @posts = site.indexed_posts.where(locale: locale) # De este tipo @posts = @posts.where(layout: filter_params[:layout]) if filter_params[:layout] # Que estén dentro de la categoría @@ -38,7 +35,7 @@ class PostsController < ApplicationController @posts = PostPolicy::Scope.new(current_usuarie, @posts).resolve # Filtrar los posts que les invitades no pueden ver - @usuarie = @site.usuarie? current_usuarie + @usuarie = site.usuarie? current_usuarie end end diff --git a/db/schema.rb b/db/schema.rb index 86354240..107e7be7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_05_11_211357) do +ActiveRecord::Schema.define(version: 2021_05_14_165639) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm"