remove anti voters, extend post vote lifetime to 90 days, add minimum score threshold for super voters
This commit is contained in:
@@ -1,8 +0,0 @@
|
|||||||
class AntiVotersController < ApplicationController
|
|
||||||
before_filter :member_only
|
|
||||||
|
|
||||||
def index
|
|
||||||
@anti_voters = AntiVoter.all
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
require "set"
|
require "set"
|
||||||
|
|
||||||
class PostVoteSimilarity
|
class PostVoteSimilarity
|
||||||
|
THRESHOLD = 0.08
|
||||||
|
|
||||||
class Element
|
class Element
|
||||||
attr_reader :user_id, :score
|
attr_reader :user_id, :score
|
||||||
|
|
||||||
@@ -20,19 +22,6 @@ class PostVoteSimilarity
|
|||||||
@user_id = user_id
|
@user_id = user_id
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns user ids with strong negative correlation
|
|
||||||
def calculate_negative(limit = 10)
|
|
||||||
posts0 = PostVote.negative_post_ids(user_id)
|
|
||||||
set = SortedSet.new
|
|
||||||
|
|
||||||
PostVote.positive_user_ids.each do |uid|
|
|
||||||
posts1 = PostVote.positive_post_ids(uid)
|
|
||||||
set.add(Element.new(uid, calculate_with_cosine(posts0, posts1)))
|
|
||||||
end
|
|
||||||
|
|
||||||
set.first(limit)
|
|
||||||
end
|
|
||||||
|
|
||||||
# returns user ids with strong positive correlation
|
# returns user ids with strong positive correlation
|
||||||
def calculate_positive(limit = 10)
|
def calculate_positive(limit = 10)
|
||||||
posts0 = PostVote.positive_post_ids(user_id)
|
posts0 = PostVote.positive_post_ids(user_id)
|
||||||
@@ -40,7 +29,10 @@ class PostVoteSimilarity
|
|||||||
|
|
||||||
PostVote.positive_user_ids.each do |uid|
|
PostVote.positive_user_ids.each do |uid|
|
||||||
posts1 = PostVote.positive_post_ids(uid)
|
posts1 = PostVote.positive_post_ids(uid)
|
||||||
set.add(Element.new(uid, calculate_with_cosine(posts0, posts1)))
|
score = calculate_with_cosine(posts0, posts1)
|
||||||
|
if score >= THRESHOLD
|
||||||
|
set.add(Element.new(uid, score))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
set.first(limit)
|
set.first(limit)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class PostVote < ActiveRecord::Base
|
|||||||
after_destroy :update_post_on_destroy
|
after_destroy :update_post_on_destroy
|
||||||
|
|
||||||
def self.prune!
|
def self.prune!
|
||||||
where("created_at < ?", 30.days.ago).delete_all
|
where("created_at < ?", 90.days.ago).delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.positive_user_ids
|
def self.positive_user_ids
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
<div id="c-super-voters">
|
|
||||||
<div id="a-index">
|
|
||||||
<h1>Anti Voters</h1>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<% @anti_voters.each do |anti_voter| %>
|
|
||||||
<li><%= link_to_if CurrentUser.user.is_janitor?, anti_voter.user.name, posts_path(tags: "upvote:#{anti_voter.user.name}") %></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% content_for(:page_title) do %>
|
|
||||||
Anti Voters - <%= Danbooru.config.app_name %>
|
|
||||||
<% end %>
|
|
||||||
@@ -71,7 +71,6 @@ Rails.application.routes.draw do
|
|||||||
resources :hits, :controller => "advertisement_hits", :only => [:create]
|
resources :hits, :controller => "advertisement_hits", :only => [:create]
|
||||||
end
|
end
|
||||||
resources :api_keys, :only => [:new, :create]
|
resources :api_keys, :only => [:new, :create]
|
||||||
resources :anti_voters, :only => [:index]
|
|
||||||
resources :artists do
|
resources :artists do
|
||||||
member do
|
member do
|
||||||
put :revert
|
put :revert
|
||||||
|
|||||||
Reference in New Issue
Block a user