fixes #1416; more consistent metatag parser code

This commit is contained in:
Toks
2013-04-22 13:44:48 -04:00
parent 2e1506f734
commit 4dbd546ff2
2 changed files with 18 additions and 12 deletions

View File

@@ -193,13 +193,17 @@ class PostQueryBuilder
has_constraints!
end
if q[:commenter_id]
relation = relation.where(:id => Comment.where("creator_id = ?", q[:commenter_id]).select("post_id").uniq)
if q[:commenter_ids]
q[:commenter_ids].each do |commenter_id|
relation = relation.where(:id => Comment.where("creator_id = ?", commenter_id).select("post_id").uniq)
end
has_constraints!
end
if q[:noter_id]
relation = relation.where(:id => Note.where("creator_id = ?", q[:noter_id]).select("post_id").uniq)
if q[:noter_ids]
q[:noter_ids].each do |noter_id|
relation = relation.where(:id => Note.where("creator_id = ?", noter_id).select("post_id").uniq)
end
has_constraints!
end

View File

@@ -302,8 +302,8 @@ class Tag < ActiveRecord::Base
q[:uploader_id_neg] << user_id unless user_id.blank?
when "user"
q[:uploader_id] = User.name_to_id($2)
q[:uploader_id] = -1 if q[:uploader_id].blank?
user_id = User.name_to_id($2)
q[:uploader_id] = user_id unless user_id.blank?
when "-approver"
q[:approver_id_neg] ||= []
@@ -311,16 +311,18 @@ class Tag < ActiveRecord::Base
q[:approver_id_neg] << user_id unless user_id.blank?
when "approver"
q[:approver_id] = User.name_to_id($2)
q[:approver_id] = -1 if q[:approver_id].blank?
user_id = User.name_to_id($2)
q[:approver_id] = user_id unless user_id.blank?
when "commenter", "comm"
q[:commenter_id] = User.name_to_id($2)
q[:commenter_id] = -1 if q[:commenter_id].blank?
q[:commenter_ids] ||= []
user_id = User.name_to_id($2)
q[:commenter_ids] << user_id unless user_id.blank?
when "noter"
q[:noter_id] = User.name_to_id($2)
q[:noter_id] = -1 if q[:noter_id].blank?
q[:noter_ids] ||= []
user_id = User.name_to_id($2)
q[:noter_ids] << user_id unless user_id.blank?
when "-pool"
q[:tags][:exclude] << "pool:#{Pool.name_to_id($2)}"