remove anti voters, extend post vote lifetime to 90 days, add minimum score threshold for super voters

This commit is contained in:
r888888888
2016-09-23 11:03:09 -07:00
parent c8c99e9b9c
commit 09ec2dfc08
5 changed files with 7 additions and 39 deletions

View File

@@ -1,8 +0,0 @@
class AntiVotersController < ApplicationController
before_filter :member_only
def index
@anti_voters = AntiVoter.all
end
end

View File

@@ -1,6 +1,8 @@
require "set"
class PostVoteSimilarity
THRESHOLD = 0.08
class Element
attr_reader :user_id, :score
@@ -20,19 +22,6 @@ class PostVoteSimilarity
@user_id = user_id
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
def calculate_positive(limit = 10)
posts0 = PostVote.positive_post_ids(user_id)
@@ -40,7 +29,10 @@ class PostVoteSimilarity
PostVote.positive_user_ids.each do |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
set.first(limit)

View File

@@ -9,7 +9,7 @@ class PostVote < ActiveRecord::Base
after_destroy :update_post_on_destroy
def self.prune!
where("created_at < ?", 30.days.ago).delete_all
where("created_at < ?", 90.days.ago).delete_all
end
def self.positive_user_ids

View File

@@ -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 %>

View File

@@ -71,7 +71,6 @@ Rails.application.routes.draw do
resources :hits, :controller => "advertisement_hits", :only => [:create]
end
resources :api_keys, :only => [:new, :create]
resources :anti_voters, :only => [:index]
resources :artists do
member do
put :revert