From d5a2ed65f8944c5542280f67fda69f7cb940b662 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 2 Sep 2019 22:18:32 -0500 Subject: [PATCH] saved searches: add 'created' and 'posts' columns to index page. --- app/models/saved_search.rb | 5 +++++ app/views/saved_searches/index.html.erb | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/saved_search.rb b/app/models/saved_search.rb index d9090f189..120858e6b 100644 --- a/app/models/saved_search.rb +++ b/app/models/saved_search.rb @@ -41,6 +41,11 @@ class SavedSearch < ApplicationRecord (REDIS_EXPIRY.to_i - ttl).seconds.ago end memoize :refreshed_at + + def cached_size + SavedSearch.redis.scard("search:#{query}") + end + memoize :cached_size end concerning :Labels do diff --git a/app/views/saved_searches/index.html.erb b/app/views/saved_searches/index.html.erb index a65411a9e..746c6b07c 100644 --- a/app/views/saved_searches/index.html.erb +++ b/app/views/saved_searches/index.html.erb @@ -18,7 +18,9 @@ Query Labels - Last Refreshed + Posts + Refreshed + Created @@ -32,6 +34,7 @@ <%= link_to label, posts_path(:tags => "search:#{label}") %> <% end %> + <%= ss.cached_size if ss.cached_size > 0 %> <% if ss.refreshed_at.present? %> <%= time_ago_in_words_tagged ss.refreshed_at %> @@ -39,6 +42,7 @@ ><%= SavedSearch::REDIS_EXPIRY.inspect %> ago <% end %> + <%= time_ago_in_words_tagged ss.created_at %> <%= link_to "edit", edit_saved_search_path(ss) %> | <%= link_to "delete", saved_search_path(ss), :method => :delete, :remote => true %>