This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon/app/controllers/api/v1
Akihiko Odaki ae871c4d46
Make Array-creation behavior of Paginable more predictable (#14687)
* Make Array-creation behavior of Paginable more predictable

Paginable.paginate_by_id usually returns ActiveRecord::Relation, but it
returns an Array if min_id option is present. The behavior caused problems
fixed with the following commits:
- 552e886b64
- b63ede5005
- 64ef37b89d

To prevent from recurring similar problems, this commit introduces two
changes:
- The scope now always returns an Array whether min_id option is present
  or not.
- The scope is renamed to to_a_paginated_by_id to clarify it returns an
  Array.

* Transform Paginable.to_a_paginated_by_id from a scope to a class method

https://api.rubyonrails.org/classes/ActiveRecord/Scoping/Named/ClassMethods.html#method-i-scope
> The method is intended to return an ActiveRecord::Relation object, which
> is composable with other scopes.

Paginable.to_a_paginated_by_id returns an Array and is not appropriate
as a scope.
2020-08-31 12:47:09 +02:00
..
accounts Introduce ApplicationController#cache_collection_paginated_by_id (#14677) 2020-08-28 12:31:56 +02:00
admin Make Array-creation behavior of Paginable more predictable (#14687) 2020-08-31 12:47:09 +02:00
announcements
apps Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
crypto Make Array-creation behavior of Paginable more predictable (#14687) 2020-08-31 12:47:09 +02:00
featured_tags Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
instances Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
lists
polls Add more tests for ActivityPub controllers (#13585) 2020-05-03 16:30:36 +02:00
push Add more tests for ActivityPub controllers (#13585) 2020-05-03 16:30:36 +02:00
statuses Fix not being able to unbookmark toots when blocked by their author (#14604) 2020-08-19 19:02:06 +02:00
timelines Introduce ApplicationController#cache_collection_paginated_by_id (#14677) 2020-08-28 12:31:56 +02:00
accounts_controller.rb Add specific rate limits for posting and following (#13172) 2020-03-08 15:17:39 +01:00
announcements_controller.rb
apps_controller.rb
blocks_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
bookmarks_controller.rb Make Array-creation behavior of Paginable more predictable (#14687) 2020-08-31 12:47:09 +02:00
conversations_controller.rb Make Array-creation behavior of Paginable more predictable (#14687) 2020-08-31 12:47:09 +02:00
custom_emojis_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
directories_controller.rb
domain_blocks_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
endorsements_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
favourites_controller.rb Make Array-creation behavior of Paginable more predictable (#14687) 2020-08-31 12:47:09 +02:00
featured_tags_controller.rb
filters_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
follow_requests_controller.rb
instances_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
lists_controller.rb
markers_controller.rb
media_controller.rb Add customizable thumbnails for audio and video attachments (#14145) 2020-06-29 13:56:55 +02:00
mutes_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
notifications_controller.rb Introduce ApplicationController#cache_collection_paginated_by_id (#14677) 2020-08-28 12:31:56 +02:00
polls_controller.rb Add more tests for ActivityPub controllers (#13585) 2020-05-03 16:30:36 +02:00
preferences_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
reports_controller.rb Add rate limit for reporting (#13390) 2020-04-05 14:40:08 +02:00
scheduled_statuses_controller.rb Make Array-creation behavior of Paginable more predictable (#14687) 2020-08-31 12:47:09 +02:00
statuses_controller.rb Fix/14021 behaviour on add or remove toots (#14212) 2020-07-19 17:04:02 +02:00
streaming_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
suggestions_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00
trends_controller.rb Remove useless `respond_to` calls (#13208) 2020-03-06 01:29:38 +01:00