Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable pagination links via config #1917

Merged
merged 1 commit into from
Sep 6, 2016

Conversation

richmolj
Copy link
Contributor

@richmolj richmolj commented Sep 6, 2016

Purpose

Add configuration option to disable automatic jsonapi pagination links.

As my application does not make use of these links, I'd like to avoid the extra database query they cause (a count to get the total pages).

Changes

Adds ActiveModel::Serializer.config.jsonapi_pagination_links_enabled. Default is true.

Related GitHub issues

#1596
#1823

@mention-bot
Copy link

@richmolj, thanks for your PR! By analyzing the annotation information on this pull request, we identified @domitian, @bf4 and @bmorrall to be potential reviewers

@richmolj richmolj force-pushed the disable_pagination_links branch from 7241ce5 to adba526 Compare September 6, 2016 17:34
@@ -52,6 +52,8 @@ def json_key
# rubocop:enable Metrics/CyclomaticComplexity

def paginated?
return false unless Serializer.config.jsonapi_pagination_links_enabled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just ActiveModelSerializers.config.jsonapi_pagination_links_enabled && :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed 👍

@richmolj richmolj force-pushed the disable_pagination_links branch from adba526 to 55fe981 Compare September 6, 2016 18:53
@@ -52,7 +52,8 @@ def json_key
# rubocop:enable Metrics/CyclomaticComplexity

def paginated?
object.respond_to?(:current_page) &&
Serializer.config.jsonapi_pagination_links_enabled &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Serializer/ActiveModelSerializers. the Serializer is no longer the primary object..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not realize this, thank you. Changed.

@richmolj richmolj force-pushed the disable_pagination_links branch from 55fe981 to 19b5abf Compare September 6, 2016 19:07
@bf4
Copy link
Member

bf4 commented Sep 6, 2016

@richmolj You wanna merge it?

@richmolj richmolj merged commit 2ea8bb7 into rails-api:master Sep 6, 2016
@richmolj richmolj deleted the disable_pagination_links branch September 6, 2016 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants