Kill trailing whitespace in ruby files

This commit is contained in:
小太
2013-03-19 23:10:10 +11:00
parent c107f96cec
commit cba839ba76
319 changed files with 2710 additions and 2710 deletions

View File

@@ -1,24 +1,24 @@
class PostQueryBuilder
attr_accessor :query_string, :has_constraints
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)
@@ -38,7 +38,7 @@ class PostQueryBuilder
when :lte
relation.where(["#{field} <= ?", arr[1]])
when :in
relation.where(["#{field} in (?)", arr[1]])
@@ -76,10 +76,10 @@ class PostQueryBuilder
if tag_query_sql.any?
relation = relation.where("posts.tag_index @@ to_tsquery('danbooru', E?)", tag_query_sql.join(" & "))
end
relation
end
def add_tag_subscription_relation(subscriptions, relation)
subscriptions.each do |subscription|
if subscription =~ /^(.+?):(.+)$/
@@ -93,25 +93,25 @@ class PostQueryBuilder
return relation if user.nil?
post_ids = TagSubscription.find_post_ids(user.id)
end
post_ids = [0] if post_ids.empty?
relation = relation.where(["posts.id IN (?)", post_ids])
end
relation
end
def build
unless query_string.is_a?(Hash)
q = Tag.parse_query(query_string)
end
relation = Post.scoped
if q[:tag_count].to_i > Danbooru.config.tag_query_limit
raise ::Post::SearchError.new("You cannot search for more than #{Danbooru.config.tag_query_limit} tags at a time")
end
relation = add_range_relation(q[:post_id], "posts.id", relation)
relation = add_range_relation(q[:mpixels], "posts.image_width * posts.image_height / 1000000.0", relation)
relation = add_range_relation(q[:width], "posts.image_width", relation)
@@ -125,12 +125,12 @@ class PostQueryBuilder
relation = add_range_relation(q[:character_tag_count], "posts.tag_count_character", relation)
relation = add_range_relation(q[:post_tag_count], "posts.tag_count", relation)
relation = add_range_relation(q[:pixiv], "substring(posts.source, 'pixiv.net/img.*/([0-9]+)[^/]*$')::integer", relation)
if q[:md5]
relation = relation.where(["posts.md5 IN (?)", q[:md5]])
has_constraints!
end
if q[:status] == "pending"
relation = relation.where("posts.is_pending = TRUE")
elsif q[:status] == "flagged"
@@ -167,26 +167,26 @@ class PostQueryBuilder
if q[:uploader_id_neg]
relation = relation.where("posts.uploader_id not in (?)", q[:uploader_id_neg])
end
if q[:uploader_id]
relation = relation.where("posts.uploader_id = ?", q[:uploader_id])
has_constraints!
end
if q[:approver_id_neg]
relation = relation.where("posts.approver_id not in (?)", q[:approver_id_neg])
end
if q[:approver_id]
relation = relation.where("posts.approver_id = ?", q[:approver_id])
has_constraints!
end
if q[:parent_id]
relation = relation.where("(posts.id = ? or posts.parent_id = ?)", q[:parent_id], q[:parent_id])
has_constraints!
end
if q[:rating] =~ /^q/
relation = relation.where("posts.rating = 'q'")
elsif q[:rating] =~ /^s/
@@ -202,13 +202,13 @@ class PostQueryBuilder
elsif q[:rating_negated] =~ /^e/
relation = relation.where("posts.rating <> 'e'")
end
relation = add_tag_string_search_relation(q[:tags], relation)
if q[:order] == "rank"
relation = relation.where("posts.score > 0 and posts.created_at >= ?", 2.days.ago)
end
case q[:order]
when "id", "id_asc"
relation = relation.order("posts.id ASC")
@@ -221,10 +221,10 @@ class PostQueryBuilder
when "score_asc"
relation = relation.order("posts.score ASC, posts.id DESC")
when "favcount"
relation = relation.order("posts.fav_count DESC, posts.id DESC")
when "favcount_asc"
relation = relation.order("posts.fav_count ASC, posts.id DESC")