saved searches: add 'created' and 'posts' columns to index page.

This commit is contained in:
evazion
2019-09-02 22:18:32 -05:00
parent 05d8a05106
commit d5a2ed65f8
2 changed files with 10 additions and 1 deletions

View File

@@ -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

View File

@@ -18,7 +18,9 @@
<tr>
<th data-sort="string">Query</th>
<th data-sort="string">Labels</th>
<th>Last Refreshed</th>
<th>Posts</th>
<th>Refreshed</th>
<th>Created</th>
<th class="links"></th>
</tr>
</thead>
@@ -32,6 +34,7 @@
<%= link_to label, posts_path(:tags => "search:#{label}") %>
<% end %>
</td>
<td><%= ss.cached_size if ss.cached_size > 0 %></td>
<td>
<% if ss.refreshed_at.present? %>
<%= time_ago_in_words_tagged ss.refreshed_at %>
@@ -39,6 +42,7 @@
&gt;<%= SavedSearch::REDIS_EXPIRY.inspect %> ago
<% end %>
</td>
<td><%= time_ago_in_words_tagged ss.created_at %></td>
<td class="links">
<%= link_to "edit", edit_saved_search_path(ss) %>
| <%= link_to "delete", saved_search_path(ss), :method => :delete, :remote => true %>