Merge pull request #2879 from evazion/fix-dead-code

Eliminate dead code
This commit is contained in:
Albert Yi
2017-02-07 13:56:05 -08:00
committed by GitHub
36 changed files with 1 additions and 285 deletions

View File

@@ -158,10 +158,6 @@ class ForumTopic < ActiveRecord::Base
(response_count / Danbooru.config.posts_per_page.to_f).ceil
end
def presenter(forum_posts)
@presenter ||= ForumTopicPresenter.new(self, forum_posts)
end
def as_json(options = {})
if CurrentUser.user.level < min_level
options[:only] = [:id]

View File

@@ -89,10 +89,6 @@ class Note < ActiveRecord::Base
extend SearchMethods
include ApiMethods
def presenter
@presenter ||= NotePresenter.new(self)
end
def initialize_creator
self.creator_id ||= CurrentUser.id
end

View File

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

View File

@@ -56,10 +56,6 @@ class PostVersion < ActiveRecord::Base
@tag_array ||= tags.scan(/\S+/)
end
def presenter
PostVersionPresenter.new(self)
end
def reload
@tag_array = nil
super

View File

@@ -79,12 +79,6 @@ class Tag < ActiveRecord::Base
end
end
module ViewCountMethods
def increment_view_count(name)
Cache.incr("tvc:#{Cache.sanitize(name)}")
end
end
module CategoryMethods
module ClassMethods
def categories
@@ -694,20 +688,6 @@ class Tag < ActiveRecord::Base
end
end
module SuggestionMethods
def find_suggestions(query)
query_tokens = query.split(/_/)
if query_tokens.size == 2
search_for = query_tokens.reverse.join("_").to_escaped_for_sql_like
else
search_for = "%" + query.to_escaped_for_sql_like + "%"
end
Tag.where(["name LIKE ? ESCAPE E'\\\\' AND post_count > 0 AND name <> ?", search_for, query]).order("post_count DESC").limit(6).select("name").map(&:name).sort
end
end
module SearchMethods
def name_matches(name)
where("tags.name LIKE ? ESCAPE E'\\\\'", name.mb_chars.downcase.to_escaped_for_sql_like)
@@ -789,12 +769,10 @@ class Tag < ActiveRecord::Base
include ApiMethods
include CountMethods
extend ViewCountMethods
include CategoryMethods
extend StatisticsMethods
extend NameMethods
extend ParseMethods
include RelationMethods
extend SuggestionMethods
extend SearchMethods
end