pools: allow searching pools by post id or post count.

All pools containing post #1:

    https://danbooru.donmai.us/pools?search[post_ids_include]=1

All pools containing either post #1 or #2:

    https://danbooru.donmai.us/pools?search[post_ids_include]=1,2
    https://danbooru.donmai.us/pools?search[post_ids_include]=1+2

Pools with 1-100 posts:

    https://danbooru.donmai.us/pools?search[post_id_count]=1..100

Pools with no posts (empty pools):

    https://danbooru.donmai.us/pools?search[post_id_count]=0
This commit is contained in:
evazion
2019-09-06 16:18:29 -05:00
parent 7d07b5f289
commit a9b7503aa7
3 changed files with 54 additions and 3 deletions

View File

@@ -57,7 +57,7 @@ class Pool < ApplicationRecord
def search(params)
q = super
q = q.search_attributes(params, :creator, :is_active, :is_deleted, :name, :description)
q = q.search_attributes(params, :creator, :is_active, :is_deleted, :name, :description, :post_ids)
q = q.text_attribute_matches(:description, params[:description_matches])
if params[:name_matches].present?