Merge branch 'master' of github.com:r888888888/danbooru

This commit is contained in:
Toks
2015-11-26 19:36:23 -05:00
14 changed files with 215 additions and 30 deletions

View File

@@ -101,6 +101,21 @@ class PostQueryBuilder
relation
end
def add_saved_search_relation(saved_searches, relation)
saved_searches.each do |saved_search|
if saved_search == "all"
post_ids = SavedSearch.post_ids(CurrentUser.id)
else
post_ids = SavedSearch.post_ids(CurrentUser.id, saved_search)
end
post_ids = [0] if post_ids.empty?
relation = relation.where(["posts.id IN (?)", post_ids])
end
relation
end
def build(relation = nil)
unless query_string.is_a?(Hash)
q = Tag.parse_query(query_string)
@@ -208,6 +223,11 @@ class PostQueryBuilder
has_constraints!
end
if q[:saved_searches]
relation = add_saved_search_relation(q[:saved_searches], relation)
has_constraints!
end
if q[:uploader_id_neg]
relation = relation.where("posts.uploader_id not in (?)", q[:uploader_id_neg])
end