fixes #2066
This commit is contained in:
@@ -1,2 +1,7 @@
|
||||
module TagsHelper
|
||||
def tag_post_count_style(tag)
|
||||
@highest_post_count ||= Tag.highest_post_count
|
||||
width_percent = Math.log(tag.post_count, @highest_post_count) * 100
|
||||
"background: linear-gradient(to left, #DDD #{width_percent}%, white #{width_percent}%)"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,6 +41,12 @@ class Tag < ActiveRecord::Base
|
||||
def counts_for(tag_names)
|
||||
select_all_sql("SELECT name, post_count FROM tags WHERE name IN (?)", tag_names)
|
||||
end
|
||||
|
||||
def highest_post_count
|
||||
Cache.get("highest-post-count", 4.hours) do
|
||||
select("post_count").order("post_count DESC").first.post_count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def real_post_count
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<tbody>
|
||||
<% @tags.each do |tag| %>
|
||||
<tr>
|
||||
<td><%= tag.post_count %></td>
|
||||
<td style="<%= tag_post_count_style(tag) %>"><%= tag.post_count %></td>
|
||||
<td class="category-<%= tag.category %>">
|
||||
<%= link_to("?", show_or_new_wiki_pages_path(:title => tag.name)) %>
|
||||
<%= link_to(tag.name, posts_path(:tags => tag.name)) %>
|
||||
|
||||
Reference in New Issue
Block a user