From 09ec2dfc08c582bfb35084dbe66aa66143ce5d38 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Fri, 23 Sep 2016 11:03:09 -0700 Subject: [PATCH] remove anti voters, extend post vote lifetime to 90 days, add minimum score threshold for super voters --- app/controllers/anti_voters_controller.rb | 8 -------- app/logical/post_vote_similarity.rb | 20 ++++++-------------- app/models/post_vote.rb | 2 +- app/views/anti_voters/index.html.erb | 15 --------------- config/routes.rb | 1 - 5 files changed, 7 insertions(+), 39 deletions(-) delete mode 100644 app/controllers/anti_voters_controller.rb delete mode 100644 app/views/anti_voters/index.html.erb diff --git a/app/controllers/anti_voters_controller.rb b/app/controllers/anti_voters_controller.rb deleted file mode 100644 index 597b459d3..000000000 --- a/app/controllers/anti_voters_controller.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AntiVotersController < ApplicationController - before_filter :member_only - - def index - @anti_voters = AntiVoter.all - end -end - diff --git a/app/logical/post_vote_similarity.rb b/app/logical/post_vote_similarity.rb index f83e6b820..761a4879e 100644 --- a/app/logical/post_vote_similarity.rb +++ b/app/logical/post_vote_similarity.rb @@ -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) diff --git a/app/models/post_vote.rb b/app/models/post_vote.rb index d92f9fe20..a3d7eb143 100644 --- a/app/models/post_vote.rb +++ b/app/models/post_vote.rb @@ -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 diff --git a/app/views/anti_voters/index.html.erb b/app/views/anti_voters/index.html.erb deleted file mode 100644 index 3c2f96d54..000000000 --- a/app/views/anti_voters/index.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -
-
-

Anti Voters

- -
    - <% @anti_voters.each do |anti_voter| %> -
  • <%= link_to_if CurrentUser.user.is_janitor?, anti_voter.user.name, posts_path(tags: "upvote:#{anti_voter.user.name}") %>
  • - <% end %> -
-
-
- -<% content_for(:page_title) do %> - Anti Voters - <%= Danbooru.config.app_name %> -<% end %> diff --git a/config/routes.rb b/config/routes.rb index 3f409255b..9f9f6947f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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