Commit Graph

59 Commits

Author SHA1 Message Date
evazion
6e5e07022d Have single result searches go to the show pages for certain controllers #4204 2019-11-04 14:24:10 -06:00
evazion
6424a4de74 Do full page counts on small index pages.
Normally we skip doing page counts on index pages when there aren't any
search filters. This is on the assumption that most index pages have
more than 1000 pages (20,000 results), so it's not worth counting them
exactly. This isn't always true, so here we turn on full counts on
certain index pages known to be small.
2019-10-28 15:18:54 -05:00
evazion
30091b989d /pools: fix pagination typo. 2019-10-08 00:50:27 -05:00
evazion
a5ab25d0ba pagination: avoid counting pages outside searches.
Replace this common pattern in controllers:

    @tags = Tag.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])

with this:

    @tags = Tag.paginated_search(params)

`search_count` is used to skip doing a full page count when we're not
doing a search (on the assumption that the number of results will be
high when not constrained by a search). We didn't do this consistently
though. Refactor to do this in every controller.
2019-10-07 22:02:03 -05:00
evazion
22fd90eee9 api: support the expiry param on all GET requests. 2019-09-08 15:32:31 -05:00
evazion
3f7e05316d api: refactor default options for xml responses.
In xml responses, if the result is an empty array we want the response
to look like this:

   <posts type="array"/>

not like this (the default):

   <nil-classes type="array"/>

This refactors controllers so that this is done automatically instead of
having to manually call `@things.to_xml(root: "things")` everywhere. We
do this by overriding the behavior of `respond_with` in `ApplicationResponder`
to set the `root` option by default in xml responses.
2019-09-08 15:32:31 -05:00
evazion
7cc31b97c9 pools/show: fix pagination to respect user's posts-per-page setting. 2019-08-21 14:31:58 -05:00
evazion
59b277ead1 users: drop id_to_name, name_to_id caching.
Changes:

* Drop Users.id_to_name.
* Don't cache Users.name_to_id.
* Replace calls to name_to_id with find_by_name when possible.
* Don't autodefine creator_name in belongs_to_creator.
* Don't autodefine updater_name in belongs_to_updater.
* Instead manually define creator_name / updater_name only on models that need
  to return these fields in the api.

id_to_name was cached to reduce the impact of N+1 query patterns in
certain places, especially in api responses that return creator_name /
updater_name fields. But it still meant we were doing N calls to
memcache. Using `includes` to prefetch users avoids this N+1 pattern.

name_to_id had no need be cached, it was never used in any performance-
sensitive contexts.

Avoiding caching also avoids the need to keep these caches consistent.
2019-08-18 11:24:42 -05:00
evazion
4f024d2360 pools/show: fix N+1 query on pool show page.
Fix a N+1 query when fetching posts to render thumbnails. Also adds
support for the `limit` url param on the posts show page.
2019-08-09 00:05:50 -05:00
Albert Yi
60cee5f452 Merge pull request #3989 from evazion/fix-3987
Wiki pages: convert other_names column to array (#3987)
2018-11-19 16:23:32 -08:00
evazion
29fdfc42a4 pools/gallery: allow searching for collection pools (#3992).
Default to showing only series pools when not doing a search. Otherwise,
when doing a search, show both series and collection pools.
2018-11-15 12:22:51 -06:00
evazion
b660aeefd7 application record: add array_attribute method.
Add `array_attribute` method that defines helper methods for converting
array attributes to or from strings.
2018-11-13 19:18:11 -06:00
evazion
115ed16a96 pools: store post_ids as array instead of string (fix #3979) 2018-11-08 15:09:31 -06:00
Albert Yi
3f40929ca1 fixes #3723 2018-05-24 10:18:16 -07:00
Albert Yi
da34c95da5 add expiry parameter 2018-05-22 14:57:46 -07:00
Albert Yi
72d72fd3d0 eliminate usage of localstorage to cache tag autocomplete results (fixes #3543) 2018-05-17 09:54:37 -07:00
Albert Yi
519769d951 fixes #3706 2018-05-10 10:09:52 -07:00
r888888888
abce4d2551 Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently
ignoring it.

misc models: convert to strong params.

artist commentaries: convert to strong params.

* Disallow changing or setting post_id to a nonexistent post.

artists: convert to strong params.

* Disallow setting `is_banned` in create/update actions. Changing it
  this way instead of with the ban/unban actions would leave the artist in
  a partially banned state.

bans: convert to strong params.

* Disallow changing the user_id after the ban has been created.

comments: convert to strong params.

favorite groups: convert to strong params.

news updates: convert to strong params.

post appeals: convert to strong params.

post flags: convert to strong params.

* Disallow users from setting the `is_deleted` / `is_resolved` flags.

ip bans: convert to strong params.

user feedbacks: convert to strong params.

* Disallow users from setting `disable_dmail_notification` when creating feedbacks.
* Disallow changing the user_id after the feedback has been created.

notes: convert to strong params.

wiki pages: convert to strong params.

* Also fix non-Builders being able to delete wiki pages.

saved searches: convert to strong params.

pools: convert to strong params.

* Disallow setting `post_count` or `is_deleted` in create/update actions.

janitor trials: convert to strong params.

post disapprovals: convert to strong params.

* Factor out quick-mod bar to shared partial.
* Fix quick-mod bar to use `Post#is_approvable?` to determine visibility
  of Approve button.

dmail filters: convert to strong params.

password resets: convert to strong params.

user name change requests: convert to strong params.

posts: convert to strong params.

users: convert to strong params.

* Disallow setting password_hash, last_logged_in_at, last_forum_read_at,
  has_mail, and dmail_filter_attributes[user_id].

* Remove initialize_default_image_size (dead code).

uploads: convert to strong params.

* Remove `initialize_status` because status already defaults to pending
  in the database.

tag aliases/implications: convert to strong params.

tags: convert to strong params.

forum posts: convert to strong params.

* Disallow changing the topic_id after creating the post.
* Disallow setting is_deleted (destroy/undelete actions should be used instead).
* Remove is_sticky / is_locked (nonexistent attributes).

forum topics: convert to strong params.

* merges https://github.com/evazion/danbooru/tree/wip-rails-5.1
* lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4)
* switch to factorybot and change all references

Co-authored-by: r888888888 <r888888888@gmail.com>
Co-authored-by: evazion <noizave@gmail.com>

add diffs
2018-04-06 18:09:57 -07:00
r888888888
e0ec9ed518 fix ordering of forum posts in topics 2018-02-01 16:35:47 -08:00
BrokenEagle
d829ab3a00 Move all order logic to models
- Have a default order for each model
-- The overall default is ID DESC
- Allow for custom orderings
-- When comma-separated IDs are used
2018-01-29 11:42:53 -08:00
BrokenEagle
956bd707a5 Add additional restrictions on updating deleted pools 2017-11-20 19:31:11 -08:00
r888888888
c83a76ccce fixes #3282 2017-09-14 11:07:14 -07:00
evazion
3b9a54f681 pools: strip leading/trailing, consecutive underscores in names (fix #3263). 2017-08-10 18:33:36 -05:00
evazion
0c79d2f09e Removed unused controllers actions / routes (#3206). 2017-07-07 15:38:06 -05:00
evazion
c46b31aa9c Prevent reverting to foreign versions (fixes #2711). 2016-10-11 06:57:46 +00:00
r888888888
1d9596d7f2 fixes #2417 2015-06-29 18:17:59 -07:00
Toks
5a8674d342 fix #2239 2015-05-02 11:12:30 -04:00
Toks
cbdc78d606 #2245 make gallery obey user's per page setting 2014-09-07 00:03:23 -04:00
Toks
4f0a83f996 #2245 allow anonymous to view gallery 2014-09-06 23:58:00 -04:00
r888888888
267df896c6 fixes #2245 2014-08-25 16:41:27 -07:00
Toks
2bc5605edc Allow searching for deleted pools 2013-11-01 10:07:47 -04:00
r888888888
e5171d0610 fixes #1999 2013-09-26 17:27:47 -07:00
r888888888
bd4b018e83 fixes #1916 2013-09-04 17:34:33 -07:00
Toks
b32783c8ba fixes #1946 2013-08-18 18:24:39 -04:00
Toks
ab57c4fa09 fixes #1713 2013-07-11 21:14:18 -04:00
Toks
2016e15ce8 fixes #1508 2013-06-30 11:57:30 -04:00
Toks
d99e9c5d81 fixes #1561 2013-05-20 08:42:15 -04:00
Toks
9ccf1e0f8f add limit parameter to everything 2013-05-15 01:01:19 -04:00
Toks
240eba56c2 fixes #1429 2013-04-30 19:54:00 -04:00
albert
541dabaaf6 fixes #1108 2013-03-29 15:37:28 -04:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
56dd8707fd controller tweaks 2013-02-23 15:58:21 -05:00
albert
78f1d0f69a fixes to user search 2013-02-21 12:42:41 -05:00
albert
e7aff87c65 fix for pool selection 2013-02-19 13:30:55 -05:00
albert
eb5e526678 enable uploads 2013-02-17 21:39:15 -05:00
albert
44682156c0 fix searches 2013-02-17 21:09:25 -05:00
albert
6ba9b015e4 fixes 2013-02-17 01:38:34 -05:00
albert
779d83e253 fixed pool deletion logic 2012-03-15 18:26:39 -04:00
albert
dd5a965884 fixes 2012-03-12 17:50:45 -04:00
albert
91f71201fa fixes #131: Unable to delete pools 2011-10-15 22:36:43 -04:00