From df33901938dac11399a0558bf246ebfcc181749e Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 7 Jul 2017 16:05:23 -0500 Subject: [PATCH] PostQueryBuilder: remove unused `has_constraints` attr (#3206). This was previously used to prevent searches that contained only negated tags. No longer used. --- app/logical/post_query_builder.rb | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index 6e38d30ed..4b7bef3cf 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -1,24 +1,13 @@ class PostQueryBuilder - attr_accessor :query_string, :has_constraints + attr_accessor :query_string def initialize(query_string) @query_string = query_string - @has_constraint = false - end - - def has_constraints? - @has_constraints - end - - def has_constraints! - @has_constraints = true end def add_range_relation(arr, field, relation) return relation if arr.nil? - has_constraints! - case arr[0] when :eq if arr[1].is_a?(Time) @@ -61,12 +50,10 @@ class PostQueryBuilder if tags[:include].any? tag_query_sql << "(" + escape_string_for_tsquery(tags[:include]).join(" | ") + ")" - has_constraints! end if tags[:related].any? tag_query_sql << "(" + escape_string_for_tsquery(tags[:related]).join(" & ") + ")" - has_constraints! end if tags[:exclude].any? @@ -133,7 +120,6 @@ class PostQueryBuilder if q[:md5] relation = relation.where(["posts.md5 IN (?)", q[:md5]]) - has_constraints! end if q[:status] == "pending" @@ -180,10 +166,8 @@ class PostQueryBuilder relation = relation.where("(lower(posts.source) like ?)", "http%") elsif q[:source] =~ /^(?:https?:\/\/)?%\.?pixiv(?:\.net(?:\/img)?)?(?:%\/img\/|%\/|(?=%$))(.+)$/i relation = relation.where("SourcePattern(lower(posts.source)) LIKE lower(?) ESCAPE E'\\\\'", "pixiv/" + $1) - has_constraints! else relation = relation.where("SourcePattern(lower(posts.source)) LIKE SourcePattern(lower(?)) ESCAPE E'\\\\'", q[:source]) - has_constraints! end end @@ -194,10 +178,8 @@ class PostQueryBuilder relation = relation.where("(lower(posts.source) not like ?)", "http%") elsif q[:source_neg] =~ /^(?:https?:\/\/)?%\.?pixiv(?:\.net(?:\/img)?)?(?:%\/img\/|%\/|(?=%$))(.+)$/i relation = relation.where("SourcePattern(lower(posts.source)) NOT LIKE lower(?) ESCAPE E'\\\\'", "pixiv/" + $1) - has_constraints! else relation = relation.where("SourcePattern(lower(posts.source)) NOT LIKE SourcePattern(lower(?)) ESCAPE E'\\\\'", q[:source_neg]) - has_constraints! end end @@ -209,7 +191,6 @@ class PostQueryBuilder if q[:saved_searches] relation = add_saved_search_relation(q[:saved_searches], relation) - has_constraints! end if q[:uploader_id_neg] @@ -218,7 +199,6 @@ class PostQueryBuilder if q[:uploader_id] relation = relation.where("posts.uploader_id = ?", q[:uploader_id]) - has_constraints! end if q[:approver_id_neg] @@ -233,7 +213,6 @@ class PostQueryBuilder else relation = relation.where("posts.approver_id = ?", q[:approver_id]) end - has_constraints! end if q[:flagger_ids_neg] @@ -257,7 +236,6 @@ class PostQueryBuilder relation = relation.where("posts.id IN (?)", PostFlag.unscoped.search({:creator_id => flagger_id, :category => "normal"}).reorder("").select(:post_id).distinct) end end - has_constraints! end if q[:appealer_ids_neg] @@ -276,7 +254,6 @@ class PostQueryBuilder relation = relation.where("posts.id IN (?)", PostAppeal.unscoped.where(creator_id: appealer_id).select(:post_id).distinct) end end - has_constraints! end if q[:commenter_ids] @@ -289,7 +266,6 @@ class PostQueryBuilder relation = relation.where("posts.id": Comment.unscoped.where(creator_id: commenter_id).select(:post_id).distinct) end end - has_constraints! end if q[:noter_ids] @@ -302,21 +278,18 @@ class PostQueryBuilder relation = relation.where("posts.id": Note.unscoped.where(creator_id: noter_id).select("post_id").distinct) end end - has_constraints! end if q[:note_updater_ids] q[:note_updater_ids].each do |note_updater_id| relation = relation.where("posts.id IN (?)", NoteVersion.unscoped.where("updater_id = ?", note_updater_id).select("post_id").uniq) end - has_constraints! end if q[:artcomm_ids] q[:artcomm_ids].each do |artcomm_id| relation = relation.where("posts.id IN (?)", ArtistCommentaryVersion.unscoped.where("updater_id = ?", artcomm_id).select("post_id").uniq) end - has_constraints! end if q[:post_id_negated] @@ -329,7 +302,6 @@ class PostQueryBuilder relation = relation.where("posts.parent_id IS NOT NULL") elsif q[:parent] relation = relation.where("(posts.id = ? or posts.parent_id = ?)", q[:parent].to_i, q[:parent].to_i) - has_constraints! end if q[:parent_neg_ids]