* Continued work on improving post view templates
* Added statistics-based estimator for related tag calculator * Fleshed out IpBan class based on changes to Danbooru 1.xx
This commit is contained in:
@@ -6,4 +6,24 @@ class IpBan < ActiveRecord::Base
|
||||
def self.is_banned?(ip_addr)
|
||||
exists?(["ip_addr = ?", ip_addr])
|
||||
end
|
||||
|
||||
def self.search(user_ids)
|
||||
comments = count_by_ip_addr("comments", user_ids, "creator_id")
|
||||
posts = count_by_ip_addr("post_versions", user_ids, "updater_id")
|
||||
notes = count_by_ip_addr("note_versions", user_ids, "updater_id")
|
||||
pools = count_by_ip_addr("pool_updates", user_ids, "updater_id")
|
||||
wiki_pages = count_by_ip_addr("wiki_page_versions", user_ids, "updater_id")
|
||||
|
||||
return {
|
||||
"comments" => comments,
|
||||
"posts" => posts,
|
||||
"notes" => notes,
|
||||
"pools" => pools,
|
||||
"wiki_pages" => wiki_pages
|
||||
}
|
||||
end
|
||||
|
||||
def self.count_by_ip_addr(table, user_ids, user_id_field = "user_id")
|
||||
select_all_sql("SELECT ip_addr, count(*) FROM #{table} WHERE #{user_id_field} IN (?) GROUP BY ip_addr ORDER BY count(*) DESC", user_ids)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user