This commit is contained in:
Type-kun
2017-01-27 20:08:43 +05:00
parent 1d25d1315a
commit 8848fa2e2f
2 changed files with 18 additions and 12 deletions

View File

@@ -340,19 +340,23 @@ class PostQueryBuilder
relation = relation.order("position(' '||posts.id||' ' in ' '||(select post_ids from pools where id = #{pool_id})||' ')") relation = relation.order("position(' '||posts.id||' ' in ' '||(select post_ids from pools where id = #{pool_id})||' ')")
end end
if q[:favgroup_neg].present? if q[:favgroups_neg].present?
favgroup_id = q[:favgroup_neg].to_i q[:favgroups_neg].each do |favgroup_rec|
favgroup = FavoriteGroup.where("favorite_groups.id = ?", favgroup_id).first favgroup_id = favgroup_rec.to_i
if favgroup favgroup = FavoriteGroup.where("favorite_groups.id = ?", favgroup_id).first
relation = relation.where("posts.id NOT in (?)", favgroup.post_id_array) if favgroup
relation = relation.where("posts.id NOT in (?)", favgroup.post_id_array)
end
end end
end end
if q[:favgroup].present? if q[:favgroups].present?
favgroup_id = q[:favgroup].to_i q[:favgroups].each do |favgroup_rec|
favgroup = FavoriteGroup.where("favorite_groups.id = ?", favgroup_id).first favgroup_id = favgroup_rec.to_i
if favgroup favgroup = FavoriteGroup.where("favorite_groups.id = ?", favgroup_id).first
relation = relation.where("posts.id in (?)", favgroup.post_id_array) if favgroup
relation = relation.where("posts.id in (?)", favgroup.post_id_array)
end
end end
end end

View File

@@ -487,11 +487,13 @@ class Tag < ActiveRecord::Base
when "-favgroup" when "-favgroup"
favgroup_id = FavoriteGroup.name_to_id($2) favgroup_id = FavoriteGroup.name_to_id($2)
q[:favgroup_neg] = favgroup_id q[:favgroups_neg] ||= []
q[:favgroups_neg] << favgroup_id
when "favgroup" when "favgroup"
favgroup_id = FavoriteGroup.name_to_id($2) favgroup_id = FavoriteGroup.name_to_id($2)
q[:favgroup] = favgroup_id q[:favgroups] ||= []
q[:favgroups] << favgroup_id
when "-fav" when "-fav"
q[:tags][:exclude] << "fav:#{User.name_to_id($2)}" q[:tags][:exclude] << "fav:#{User.name_to_id($2)}"