From b5bf9b8678fed303b76ce248cb4c25e160f7dbbd Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 6 Feb 2017 06:10:33 -0600 Subject: [PATCH] post.rb: remove assorted unused methods. --- .../moderator/post/queues_controller.rb | 2 +- app/models/post.rb | 63 ------------------- 2 files changed, 1 insertion(+), 64 deletions(-) diff --git a/app/controllers/moderator/post/queues_controller.rb b/app/controllers/moderator/post/queues_controller.rb index 9e32d6aa5..06b80dd18 100644 --- a/app/controllers/moderator/post/queues_controller.rb +++ b/app/controllers/moderator/post/queues_controller.rb @@ -15,7 +15,7 @@ module Moderator end ::Post.without_timeout do - @posts = ::Post.order("posts.id asc").pending_or_flagged.available_for_moderation(params[:hidden]).search(:tag_match => params[:query]).paginate(params[:page], :limit => per_page) + @posts = ::Post.order("posts.id asc").pending_or_flagged.available_for_moderation(params[:hidden]).tag_match(params[:query]).paginate(params[:page], :limit => per_page) @posts.each # hack to force rails to eager load end respond_with(@posts) diff --git a/app/models/post.rb b/app/models/post.rb index 390bea960..70b191e9e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -531,10 +531,6 @@ class Post < ActiveRecord::Base @tag_array_was ||= Tag.scan_tags(tag_string_was) end - def increment_tag_post_counts - Tag.where(:name => tag_array).update_all("post_count = post_count + 1") if tag_array.any? - end - def decrement_tag_post_counts Tag.where(:name => tag_array).update_all("post_count = post_count - 1") if tag_array.any? end @@ -1476,10 +1472,6 @@ class Post < ActiveRecord::Base end module NoteMethods - def last_noted_at_as_integer - last_noted_at.to_i - end - def has_notes? last_noted_at.present? end @@ -1616,10 +1608,6 @@ class Post < ActiveRecord::Base where("is_deleted = ?", true) end - def commented_before(date) - where("last_commented_at < ?", date).order("last_commented_at DESC") - end - def has_notes where("last_noted_at is not null") end @@ -1636,10 +1624,6 @@ class Post < ActiveRecord::Base end end - def hidden_from_moderation - where("id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id) - end - def raw_tag_match(tag) where("posts.tag_index @@ to_tsquery('danbooru', E?)", tag.to_escaped_for_tsquery) end @@ -1656,53 +1640,6 @@ class Post < ActiveRecord::Base PostQueryBuilder.new(query).build end end - - def positive - where("score > 1") - end - - def negative - where("score < -1") - end - - def updater_name_matches(name) - where("updater_id = (select _.id from users _ where lower(_.name) = ?)", name.mb_chars.downcase) - end - - def after_id(num) - if num.present? - where("id > ?", num.to_i).reorder("id asc") - else - where("true") - end - end - - def before_id(num) - if num.present? - where("id < ?", num.to_i).reorder("id desc") - else - where("true") - end - end - - def search(params) - q = where("true") - return q if params.blank? - - if params[:before_id].present? - q = q.before_id(params[:before_id].to_i) - end - - if params[:after_id].present? - q = q.after_id(params[:after_id].to_i) - end - - if params[:tag_match].present? - q = q.tag_match(params[:tag_match]) - end - - q - end end module PixivMethods