evazion
6413b9abcd
Fix #5312 : StatementInvalid Error When Querying the media_assets Attribute of Uploads
2022-10-25 16:48:16 -05:00
evazion
530d8cf762
searchable: fix searching for invalid IP addresses.
...
Fix an ArgumentError exception when searching for an invalid IP address.
Also allow searching for multiple subnets at once.
2022-09-29 04:36:12 -05:00
evazion
c5b215ffcb
searchable: fix searching for polymorphic attributes.
...
Fix not being able to use the full set of search operators on polymorphic `model_id` and
`model_type` attributes. Before things like `search[model_type]=Post` worked, but
`search[model_type_not_eq]=Post` or other `model_type_*` operators didn't.
2022-09-29 04:36:12 -05:00
evazion
88ac91f5f3
search: refactor to pass in the current user explicitly.
2022-09-22 04:31:21 -05:00
evazion
6a9a679149
searchable: refactor search_attributes helper methods into class.
...
Move the `search_attributes` helper methods inside the Searchable
concern into a SearchContext helper class. This is so we don't have to
pass `params` and `current_user` down through a bunch of different
helper methods, and so that these private helper methods don't pollute
the object's namespace.
2022-09-22 01:48:21 -05:00
evazion
d4da8499ce
models: stop saving IP addresses in version tables.
...
Mark various `creator_ip_addr` and `updater_ip_addr` columns as ignored
and stop updating them in preparation for dropping them.
2022-09-18 03:49:17 -05:00
evazion
51ba56e8a3
Fix #5001 : Media assets not searchable through upload records.
...
Fix this:
https://danbooru.donmai.us/uploads.json?search[media_assets][md5]=b83daa7f1ae7e4127b1befd32f71ba10
failing with an ActiveRecord::StatementInvalid error.
The bug was that for a `has_many through: ...` association, like
`has_many :media_assets, through: :upload_media_assets`, we weren't
joining on the associated table properly so we ended up generating
invalid SQL.
2022-02-08 19:18:11 -06:00
evazion
c0f744f84d
Fix #4893 : Add a FIELD_present parameter variation for text fields.
...
Usage:
* https://danbooru.donmai.us/wiki_pages.json?search[body_present]=true
* https://danbooru.donmai.us/wiki_pages.json?search[body_present]=false
2021-10-13 04:10:23 -05:00
evazion
c1b865b160
searchable: add more enum attribute search options.
...
Add `<enum>_not` and `<enum>_id_<op>` search options:
* https://danbooru.donmai.us/mod_actions?search[category_not]=post_regenerate,post_regenerate_iqdb
* https://danbooru.donmai.us/mod_actions?search[category_not]=48,49
* https://danbooru.donmai.us/mod_actions?search[category_id]=40..50
* https://danbooru.donmai.us/mod_actions?search[category_id_not]=40..50
* https://danbooru.donmai.us/mod_actions?search[category_id_gt]=40&search[category_id_lt]=50
2021-01-11 19:13:35 -06:00
evazion
e7b454686e
searchable: refactor where_operator method.
...
Refactor the `where_operator` method so we can use it to avoid raw SQL
in more places.
2021-01-11 19:13:29 -06:00
evazion
6d2eeb6f28
searchable: fix being unable to use multiple operators on same attribute.
...
Fix searches like this not working:
* https://danbooru.donmai.us/tags?search[id]=1..100&search[id_not]=50
Before one of these params would override the other.
2021-01-11 14:59:04 -06:00
evazion
9759701071
search: add way to search array attributes by regex.
...
Add a `where_any_in_array_matches_regex` method and expose it to the API:
* https://danbooru.donmai.us/artists?search[any_other_name_matches_regex]= ^blah
* https://danbooru.donmai.us/wiki_pages?search[any_other_name_matches_regex]= ^blah
* https://danbooru.donmai.us/saved_searches?search[any_label_matches_regex]= ^blah
In SQL, this does `WHERE '^blah' ~<< ANY(other_names)`, where `~<<` is a
custom operator based on the `~` regex match operator, but with the
arguments reversed. This allows it to be used with the ANY(array) operator.
See also:
* https://stackoverflow.com/a/22101172
* https://www.postgresql.org/docs/current/sql-createfunction.html
* https://www.postgresql.org/docs/current/sql-createoperator.html
* https://www.postgresql.org/docs/current/functions-comparisons.html
2021-01-10 02:03:02 -06:00
evazion
da3e8e4726
searchable: fix bug with searching multiple association attributes.
...
Fix a bug with searches like the following not working correctly:
* https://danbooru.donmai.us/comments.json?search[creator][level]=20&search[creator_id]=1234
* https://danbooru.donmai.us/comments.json?search[creator][level]=20&search[creator_name]=abcd
* https://danbooru.donmai.us/comments.json?search[post][rating]=s&search[post_tags_match]=touhou
It wasn't possible to search for both `creator` and `creator_id` at the
same time (or `post` and `post_tags_match`, etc). Only the `creator_id`
param would be recognized.
Also refactor some internals:
* `search_includes` was renamed to `search_associated_attribute`.
* `search_attribute` was split up into `search_basic_attribute` and
`search_associated_attribute`.
2021-01-07 17:10:29 -06:00
evazion
b0659eb76c
searchable: add tests for Searchable concern.
2020-12-16 23:57:04 -06:00