modqueue: add sidebar.

Add a sidebar to the modqueue page that shows the following information:

* Number of pending and flagged posts.
* Number of posts disapproved for poor quality or breaking rules.
* Top uploaders in the queue.
* Top artist, copyright, and character tags in the queue.
This commit is contained in:
evazion
2020-02-29 17:04:39 -06:00
parent 475d6ae7cf
commit 9ddf408ec5
8 changed files with 128 additions and 45 deletions

View File

@@ -17,7 +17,11 @@ module RelatedTagCalculator
def self.frequent_tags_for_search(tag_query, search_sample_size: 1000, category: nil)
sample_posts = Post.tag_match(tag_query).reorder(:md5).limit(search_sample_size)
tag_counts = Post.from(sample_posts).with_unflattened_tags.group("tag").select("tag, COUNT(*) AS overlap_count")
frequent_tags_for_post_relation(sample_posts, category: category)
end
def self.frequent_tags_for_post_relation(posts, category: nil)
tag_counts = Post.from(posts).with_unflattened_tags.group("tag").select("tag, COUNT(*) AS overlap_count")
tags = Tag.from(tag_counts).joins("JOIN tags ON tags.name = tag")
tags = tags.select("tags.*, overlap_count")
@@ -27,7 +31,7 @@ module RelatedTagCalculator
tags
end
def self.frequent_tags_for_posts(posts)
def self.frequent_tags_for_post_array(posts)
tags_with_counts = posts.flat_map(&:tag_array).group_by(&:itself).transform_values(&:size)
tags_with_counts.sort_by { |tag_name, count| [-count, tag_name] }.map(&:first)
end