forked from e621ng/e621ng
fix stats page (division by zero and NaN) and add mp4 listing
This commit is contained in:
parent
cb03e2c404
commit
a6a3ad7a67
@ -35,6 +35,7 @@ class StatsUpdater
|
|||||||
stats[:gif_posts] = Post.tag_match("status:any type:gif").count_only
|
stats[:gif_posts] = Post.tag_match("status:any type:gif").count_only
|
||||||
stats[:swf_posts] = Post.tag_match("status:any type:swf").count_only
|
stats[:swf_posts] = Post.tag_match("status:any type:swf").count_only
|
||||||
stats[:webm_posts] = Post.tag_match("status:any type:webm").count_only
|
stats[:webm_posts] = Post.tag_match("status:any type:webm").count_only
|
||||||
|
stats[:mp4_posts] = Post.tag_match("status:any type:mp4").count_only
|
||||||
stats[:average_file_size] = Post.average("file_size")
|
stats[:average_file_size] = Post.average("file_size")
|
||||||
stats[:total_file_size] = Post.sum("file_size")
|
stats[:total_file_size] = Post.sum("file_size")
|
||||||
stats[:average_posts_per_day] = daily_average.call(stats[:total_posts])
|
stats[:average_posts_per_day] = daily_average.call(stats[:total_posts])
|
||||||
@ -61,7 +62,8 @@ class StatsUpdater
|
|||||||
|
|
||||||
stats[:total_forum_threads] = ForumTopic.count
|
stats[:total_forum_threads] = ForumTopic.count
|
||||||
stats[:total_forum_posts] = ForumPost.maximum("id") || 0
|
stats[:total_forum_posts] = ForumPost.maximum("id") || 0
|
||||||
stats[:average_posts_per_thread] = (stats[:total_forum_posts] / stats[:total_forum_threads]).round
|
stats[:average_posts_per_thread] = 0
|
||||||
|
stats[:average_posts_per_thread] = (stats[:total_forum_posts] / stats[:total_forum_threads]).round if stats[:total_forum_threads] > 0
|
||||||
stats[:average_forum_posts_per_day] = daily_average.call(stats[:total_forum_posts])
|
stats[:average_forum_posts_per_day] = daily_average.call(stats[:total_forum_posts])
|
||||||
|
|
||||||
### Blips ###
|
### Blips ###
|
||||||
|
@ -12,7 +12,13 @@
|
|||||||
<td><%= data_title %></td>
|
<td><%= data_title %></td>
|
||||||
<td><%= del(@stats[data_or_stats_key]) || data_or_stats_key %></td>
|
<td><%= del(@stats[data_or_stats_key]) || data_or_stats_key %></td>
|
||||||
<% if data_total_key %>
|
<% if data_total_key %>
|
||||||
<td class="stats-pct"><%= (@stats[data_or_stats_key].to_f / @stats[data_total_key] * 100).round %>%</td>
|
<td class="stats-pct">
|
||||||
|
<% if @stats[data_total_key] > 0 %>
|
||||||
|
<%= (@stats[data_or_stats_key].to_f / @stats[data_total_key] * 100).round %>%
|
||||||
|
<% else %>
|
||||||
|
0%
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
<% else %>
|
<% else %>
|
||||||
<td></td>
|
<td></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
["GIF posts", "gif_posts", "existing_posts"],
|
["GIF posts", "gif_posts", "existing_posts"],
|
||||||
["Flash posts", "swf_posts", "existing_posts"],
|
["Flash posts", "swf_posts", "existing_posts"],
|
||||||
["WebM posts", "webm_posts", "existing_posts"],
|
["WebM posts", "webm_posts", "existing_posts"],
|
||||||
|
["MP4 posts", "mp4_posts", "existing_posts"],
|
||||||
["Average file size", number_to_human_size(@stats["average_file_size"], precision: 3)],
|
["Average file size", number_to_human_size(@stats["average_file_size"], precision: 3)],
|
||||||
["Total file size", number_to_human_size(@stats["total_file_size"], precision: 3)],
|
["Total file size", number_to_human_size(@stats["total_file_size"], precision: 3)],
|
||||||
]
|
]
|
||||||
@ -89,12 +90,12 @@
|
|||||||
["Artist tag count", "artist_tags", "total_tags"],
|
["Artist tag count", "artist_tags", "total_tags"],
|
||||||
["Contributor tag count", "contributor_tags", "total_tags"],
|
["Contributor tag count", "contributor_tags", "total_tags"],
|
||||||
["Character tag count", "character_tags", "total_tags"],
|
["Character tag count", "character_tags", "total_tags"],
|
||||||
|
["People tag count", "people_tags", "total_tags"],
|
||||||
["Copyright tag count", "copyright_tags", "total_tags"],
|
["Copyright tag count", "copyright_tags", "total_tags"],
|
||||||
["Species tag count", "species_tags", "total_tags"],
|
["Species tag count", "species_tags", "total_tags"],
|
||||||
["Meta tag count", "meta_tags", "total_tags"],
|
["Meta tag count", "meta_tags", "total_tags"],
|
||||||
["Invalid tag count", "invalid_tags", "total_tags"],
|
["Invalid tag count", "invalid_tags", "total_tags"],
|
||||||
["Lore tag count", "lore_tags", "total_tags"],
|
["Lore tag count", "lore_tags", "total_tags"],
|
||||||
["People tag count", "people_tags", "total_tags"],
|
|
||||||
]
|
]
|
||||||
%>
|
%>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user