models: rename post/pool archives to post/pool versions.

This commit is contained in:
evazion
2020-02-15 06:52:10 -06:00
parent 51f3f7338a
commit 60ff2ae929
27 changed files with 71 additions and 84 deletions

View File

@@ -3,9 +3,9 @@ module Moderator
module Queries
class Tag < ::Struct.new(:user, :count)
def self.all(min_date, max_level)
return [] unless PostArchive.enabled?
return [] unless PostVersion.enabled?
records = PostArchive.where("updated_at > ?", min_date).group(:updater).count.map do |user, count|
records = PostVersion.where("updated_at > ?", min_date).group(:updater).count.map do |user, count|
new(user, count)
end

View File

@@ -32,8 +32,8 @@ module Moderator
add_row(sums, Upload.where(uploader_ip_addr: ip_addrs).group(:uploader).count)
add_row(sums, Hash[User.where(last_ip_addr: ip_addrs).collect { |user| [user, 1] }])
add_row_id(sums, PoolArchive.where(updater_ip_addr: ip_addrs).group(:updater_id).count) if PoolArchive.enabled?
add_row_id(sums, PostArchive.where(updater_ip_addr: ip_addrs).group(:updater_id).count) if PostArchive.enabled?
add_row_id(sums, PoolVersion.where(updater_ip_addr: ip_addrs).group(:updater_id).count) if PoolVersion.enabled?
add_row_id(sums, PostVersion.where(updater_ip_addr: ip_addrs).group(:updater_id).count) if PostVersion.enabled?
sums
end
@@ -50,8 +50,8 @@ module Moderator
add_row(sums, ArtistCommentaryVersion.where(updater: users).group(:updater_ip_addr).count)
add_row(sums, ArtistVersion.where(updater: users).group(:updater_ip_addr).count)
add_row(sums, NoteVersion.where(updater: users).group(:updater_ip_addr).count)
add_row(sums, PoolArchive.where(updater_id: users.map(&:id)).group(:updater_ip_addr).count) if PoolArchive.enabled?
add_row(sums, PostArchive.where(updater_id: users.map(&:id)).group(:updater_ip_addr).count) if PostArchive.enabled?
add_row(sums, PoolVersion.where(updater_id: users.map(&:id)).group(:updater_ip_addr).count) if PoolVersion.enabled?
add_row(sums, PostVersion.where(updater_id: users.map(&:id)).group(:updater_ip_addr).count) if PostVersion.enabled?
add_row(sums, WikiPageVersion.where(updater: users).group(:updater_ip_addr).count)
add_row(sums, Comment.where(creator: users).group(:creator_ip_addr).count)
add_row(sums, Dmail.where(from: users).group(:creator_ip_addr).count)

View File

@@ -28,9 +28,9 @@ class RelatedTagQuery
# Returns the top 20 most frequently added tags within the last 20 edits made by the user in the last hour.
def recent_tags(since: 1.hour.ago, max_edits: 20, max_tags: 20)
return [] unless user.present? && PostArchive.enabled?
return [] unless user.present? && PostVersion.enabled?
versions = PostArchive.where(updater_id: user.id).where("updated_at > ?", since).order(id: :desc).limit(max_edits)
versions = PostVersion.where(updater_id: user.id).where("updated_at > ?", since).order(id: :desc).limit(max_edits)
tags = versions.flat_map(&:added_tags)
tags = tags.reject { |tag| Tag.is_metatag?(tag) }
tags = tags.group_by(&:itself).transform_values(&:size).sort_by { |tag, count| [-count, tag] }.map(&:first)