{"action":"created","comment":{"url":"https://api.github.com/repos/activeadmin/activeadmin/pulls/comments/27874453","id":27874453,"diff_hunk":"@@ -117,22 +127,30 @@ def page_entries_info(options = {})\n           entries_name = I18n.translate key, count: collection.size, default: entry_name.pluralize\n         end\n \n-        if collection.num_pages < 2\n-          case collection_size\n-          when 0; I18n.t('active_admin.pagination.empty',    model: entries_name)\n-          when 1; I18n.t('active_admin.pagination.one',      model: entry_name)\n-          else;   I18n.t('active_admin.pagination.one_page', model: entries_name, n: collection.total_count)\n+        if @display_total\n+          if collection.num_pages < 2\n+            case collection_size\n+            when 0; I18n.t(\"active_admin.pagination.empty\",    model: entries_name)\n+            when 1; I18n.t(\"active_admin.pagination.one\",      model: entry_name)\n+            else;   I18n.t(\"active_admin.pagination.one_page\", model: entries_name, n: collection.total_count)\n+            end\n+          else\n+            offset = (collection.current_page - 1) * collection.limit_value\n+            total  = collection.total_count\n+            I18n.t \"active_admin.pagination.multiple\",\n+              model: entries_name,","path":"lib/active_admin/views/components/paginated_collection.rb","position":37,"original_position":37,"commit_id":"6ab8c6592496d272619bcf6e72d170eca660976c","original_commit_id":"6ab8c6592496d272619bcf6e72d170eca660976c","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Align the parameters of a method call if they span more than one line.","created_at":"2015-04-07T12:55:19Z","updated_at":"2015-04-07T12:55:19Z","html_url":"https://github.com/activeadmin/activeadmin/pull/3848#discussion_r27874453","pull_request_url":"https://api.github.com/repos/activeadmin/activeadmin/pulls/3848","_links":{"self":{"href":"https://api.github.com/repos/activeadmin/activeadmin/pulls/comments/27874453"},"html":{"href":"https://github.com/activeadmin/activeadmin/pull/3848#discussion_r27874453"},"pull_request":{"href":"https://api.github.com/repos/activeadmin/activeadmin/pulls/3848"}}},"pull_request":{"url":"https://api.github.com/repos/activeadmin/activeadmin/pulls/3848","id":30787983,"html_url":"https://github.com/activeadmin/activeadmin/pull/3848","diff_url":"https://github.com/activeadmin/activeadmin/pull/3848.diff","patch_url":"https://github.com/activeadmin/activeadmin/pull/3848.patch","issue_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/3848","number":3848,"state":"open","locked":false,"title":"Fix pagination_total index option to prevent SELECT count(*) queries","user":{"login":"losvedir","id":384428,"avatar_url":"https://avatars.githubusercontent.com/u/384428?v=3","gravatar_id":"","url":"https://api.github.com/users/losvedir","html_url":"https://github.com/losvedir","followers_url":"https://api.github.com/users/losvedir/followers","following_url":"https://api.github.com/users/losvedir/following{/other_user}","gists_url":"https://api.github.com/users/losvedir/gists{/gist_id}","starred_url":"https://api.github.com/users/losvedir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/losvedir/subscriptions","organizations_url":"https://api.github.com/users/losvedir/orgs","repos_url":"https://api.github.com/users/losvedir/repos","events_url":"https://api.github.com/users/losvedir/events{/privacy}","received_events_url":"https://api.github.com/users/losvedir/received_events","type":"User","site_admin":false},"body":"Addresses https://github.com/activeadmin/activeadmin/issues/3847.\r\n\r\nThe `pagination_total` option is supposed to prevent expensive `SELECT count(*)` queries from being performed when viewing a resource's index page.\r\n\r\nHowever, while this option was hiding the display of the total number of pages, it did not actually prevent the query from being performed.\r\n\r\nThere were two reasons:\r\n\r\nFirst, in `#build_pagination`, the line: `text_node paginate collection, options` would trigger Kaminari to call `#total_pages` on the collection, which would trigger the query. Excerpt of kaminari code:\r\n\r\n``` ruby\r\ndef paginate(scope, options = {}, &block)\r\n  options[:total_pages] ||= options[:num_pages] || scope.total_pages\r\n```\r\n\r\nBy passing in the `:total_pages` option, we short circuit this assignment and avoid the query.\r\n\r\nThe downside is we do so by hardcoding in an essentially random total pages count of 100. I chose the number 100, because I wanted to ensure ellipses would appear in Kaminari's \"Page 1, 2, 3, ..., Next, Last\" links, no matter how many links are configured to be displayed. However, if the resource only had 2 pages worth of items, then clicking the \"3\" would result in an empty page. That said, without querying the resource, there's no way to know how many pages there should be.\r\n\r\nSecond, in `#page_entries_info`, the call `collection.num_pages` also triggered a `SELECT count(*)`. I re-arranged the conditionals to avoid that call if `@display_total` is false, while trying to keep the behavior the same.","created_at":"2015-03-09T18:42:48Z","updated_at":"2015-04-07T12:55:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d63fdc8749b235719f7c7bcfda561206a2b448b6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/activeadmin/activeadmin/pulls/3848/commits","review_comments_url":"https://api.github.com/repos/activeadmin/activeadmin/pulls/3848/comments","review_comment_url":"https://api.github.com/repos/activeadmin/activeadmin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/3848/comments","statuses_url":"https://api.github.com/repos/activeadmin/activeadmin/statuses/6ab8c6592496d272619bcf6e72d170eca660976c","head":{"label":"losvedir:3847-fix-pagination-total-false","ref":"3847-fix-pagination-total-false","sha":"6ab8c6592496d272619bcf6e72d170eca660976c","user":{"login":"losvedir","id":384428,"avatar_url":"https://avatars.githubusercontent.com/u/384428?v=3","gravatar_id":"","url":"https://api.github.com/users/losvedir","html_url":"https://github.com/losvedir","followers_url":"https://api.github.com/users/losvedir/followers","following_url":"https://api.github.com/users/losvedir/following{/other_user}","gists_url":"https://api.github.com/users/losvedir/gists{/gist_id}","starred_url":"https://api.github.com/users/losvedir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/losvedir/subscriptions","organizations_url":"https://api.github.com/users/losvedir/orgs","repos_url":"https://api.github.com/users/losvedir/repos","events_url":"https://api.github.com/users/losvedir/events{/privacy}","received_events_url":"https://api.github.com/users/losvedir/received_events","type":"User","site_admin":false},"repo":{"id":31911852,"name":"activeadmin","full_name":"losvedir/activeadmin","owner":{"login":"losvedir","id":384428,"avatar_url":"https://avatars.githubusercontent.com/u/384428?v=3","gravatar_id":"","url":"https://api.github.com/users/losvedir","html_url":"https://github.com/losvedir","followers_url":"https://api.github.com/users/losvedir/followers","following_url":"https://api.github.com/users/losvedir/following{/other_user}","gists_url":"https://api.github.com/users/losvedir/gists{/gist_id}","starred_url":"https://api.github.com/users/losvedir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/losvedir/subscriptions","organizations_url":"https://api.github.com/users/losvedir/orgs","repos_url":"https://api.github.com/users/losvedir/repos","events_url":"https://api.github.com/users/losvedir/events{/privacy}","received_events_url":"https://api.github.com/users/losvedir/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/losvedir/activeadmin","description":"The administration framework for Ruby on Rails applications.","fork":true,"url":"https://api.github.com/repos/losvedir/activeadmin","forks_url":"https://api.github.com/repos/losvedir/activeadmin/forks","keys_url":"https://api.github.com/repos/losvedir/activeadmin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/losvedir/activeadmin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/losvedir/activeadmin/teams","hooks_url":"https://api.github.com/repos/losvedir/activeadmin/hooks","issue_events_url":"https://api.github.com/repos/losvedir/activeadmin/issues/events{/number}","events_url":"https://api.github.com/repos/losvedir/activeadmin/events","assignees_url":"https://api.github.com/repos/losvedir/activeadmin/assignees{/user}","branches_url":"https://api.github.com/repos/losvedir/activeadmin/branches{/branch}","tags_url":"https://api.github.com/repos/losvedir/activeadmin/tags","blobs_url":"https://api.github.com/repos/losvedir/activeadmin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/losvedir/activeadmin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/losvedir/activeadmin/git/refs{/sha}","trees_url":"https://api.github.com/repos/losvedir/activeadmin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/losvedir/activeadmin/statuses/{sha}","languages_url":"https://api.github.com/repos/losvedir/activeadmin/languages","stargazers_url":"https://api.github.com/repos/losvedir/activeadmin/stargazers","contributors_url":"https://api.github.com/repos/losvedir/activeadmin/contributors","subscribers_url":"https://api.github.com/repos/losvedir/activeadmin/subscribers","subscription_url":"https://api.github.com/repos/losvedir/activeadmin/subscription","commits_url":"https://api.github.com/repos/losvedir/activeadmin/commits{/sha}","git_commits_url":"https://api.github.com/repos/losvedir/activeadmin/git/commits{/sha}","comments_url":"https://api.github.com/repos/losvedir/activeadmin/comments{/number}","issue_comment_url":"https://api.github.com/repos/losvedir/activeadmin/issues/comments{/number}","contents_url":"https://api.github.com/repos/losvedir/activeadmin/contents/{+path}","compare_url":"https://api.github.com/repos/losvedir/activeadmin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/losvedir/activeadmin/merges","archive_url":"https://api.github.com/repos/losvedir/activeadmin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/losvedir/activeadmin/downloads","issues_url":"https://api.github.com/repos/losvedir/activeadmin/issues{/number}","pulls_url":"https://api.github.com/repos/losvedir/activeadmin/pulls{/number}","milestones_url":"https://api.github.com/repos/losvedir/activeadmin/milestones{/number}","notifications_url":"https://api.github.com/repos/losvedir/activeadmin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/losvedir/activeadmin/labels{/name}","releases_url":"https://api.github.com/repos/losvedir/activeadmin/releases{/id}","created_at":"2015-03-09T17:13:10Z","updated_at":"2015-03-09T17:13:13Z","pushed_at":"2015-04-07T12:55:15Z","git_url":"git://github.com/losvedir/activeadmin.git","ssh_url":"git@github.com:losvedir/activeadmin.git","clone_url":"https://github.com/losvedir/activeadmin.git","svn_url":"https://github.com/losvedir/activeadmin","homepage":"activeadmin.info","size":7132,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"activeadmin:master","ref":"master","sha":"88c8234b40fe1fa668caa1542ac437dda968d02e","user":{"login":"activeadmin","id":814570,"avatar_url":"https://avatars.githubusercontent.com/u/814570?v=3","gravatar_id":"","url":"https://api.github.com/users/activeadmin","html_url":"https://github.com/activeadmin","followers_url":"https://api.github.com/users/activeadmin/followers","following_url":"https://api.github.com/users/activeadmin/following{/other_user}","gists_url":"https://api.github.com/users/activeadmin/gists{/gist_id}","starred_url":"https://api.github.com/users/activeadmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/activeadmin/subscriptions","organizations_url":"https://api.github.com/users/activeadmin/orgs","repos_url":"https://api.github.com/users/activeadmin/repos","events_url":"https://api.github.com/users/activeadmin/events{/privacy}","received_events_url":"https://api.github.com/users/activeadmin/received_events","type":"Organization","site_admin":false},"repo":{"id":611921,"name":"activeadmin","full_name":"activeadmin/activeadmin","owner":{"login":"activeadmin","id":814570,"avatar_url":"https://avatars.githubusercontent.com/u/814570?v=3","gravatar_id":"","url":"https://api.github.com/users/activeadmin","html_url":"https://github.com/activeadmin","followers_url":"https://api.github.com/users/activeadmin/followers","following_url":"https://api.github.com/users/activeadmin/following{/other_user}","gists_url":"https://api.github.com/users/activeadmin/gists{/gist_id}","starred_url":"https://api.github.com/users/activeadmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/activeadmin/subscriptions","organizations_url":"https://api.github.com/users/activeadmin/orgs","repos_url":"https://api.github.com/users/activeadmin/repos","events_url":"https://api.github.com/users/activeadmin/events{/privacy}","received_events_url":"https://api.github.com/users/activeadmin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/activeadmin/activeadmin","description":"The administration framework for Ruby on Rails applications.","fork":false,"url":"https://api.github.com/repos/activeadmin/activeadmin","forks_url":"https://api.github.com/repos/activeadmin/activeadmin/forks","keys_url":"https://api.github.com/repos/activeadmin/activeadmin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/activeadmin/activeadmin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/activeadmin/activeadmin/teams","hooks_url":"https://api.github.com/repos/activeadmin/activeadmin/hooks","issue_events_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/events{/number}","events_url":"https://api.github.com/repos/activeadmin/activeadmin/events","assignees_url":"https://api.github.com/repos/activeadmin/activeadmin/assignees{/user}","branches_url":"https://api.github.com/repos/activeadmin/activeadmin/branches{/branch}","tags_url":"https://api.github.com/repos/activeadmin/activeadmin/tags","blobs_url":"https://api.github.com/repos/activeadmin/activeadmin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/activeadmin/activeadmin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/activeadmin/activeadmin/git/refs{/sha}","trees_url":"https://api.github.com/repos/activeadmin/activeadmin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/activeadmin/activeadmin/statuses/{sha}","languages_url":"https://api.github.com/repos/activeadmin/activeadmin/languages","stargazers_url":"https://api.github.com/repos/activeadmin/activeadmin/stargazers","contributors_url":"https://api.github.com/repos/activeadmin/activeadmin/contributors","subscribers_url":"https://api.github.com/repos/activeadmin/activeadmin/subscribers","subscription_url":"https://api.github.com/repos/activeadmin/activeadmin/subscription","commits_url":"https://api.github.com/repos/activeadmin/activeadmin/commits{/sha}","git_commits_url":"https://api.github.com/repos/activeadmin/activeadmin/git/commits{/sha}","comments_url":"https://api.github.com/repos/activeadmin/activeadmin/comments{/number}","issue_comment_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/comments{/number}","contents_url":"https://api.github.com/repos/activeadmin/activeadmin/contents/{+path}","compare_url":"https://api.github.com/repos/activeadmin/activeadmin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/activeadmin/activeadmin/merges","archive_url":"https://api.github.com/repos/activeadmin/activeadmin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/activeadmin/activeadmin/downloads","issues_url":"https://api.github.com/repos/activeadmin/activeadmin/issues{/number}","pulls_url":"https://api.github.com/repos/activeadmin/activeadmin/pulls{/number}","milestones_url":"https://api.github.com/repos/activeadmin/activeadmin/milestones{/number}","notifications_url":"https://api.github.com/repos/activeadmin/activeadmin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/activeadmin/activeadmin/labels{/name}","releases_url":"https://api.github.com/repos/activeadmin/activeadmin/releases{/id}","created_at":"2010-04-15T14:26:03Z","updated_at":"2015-04-07T10:51:24Z","pushed_at":"2015-04-07T12:55:16Z","git_url":"git://github.com/activeadmin/activeadmin.git","ssh_url":"git@github.com:activeadmin/activeadmin.git","clone_url":"https://github.com/activeadmin/activeadmin.git","svn_url":"https://github.com/activeadmin/activeadmin","homepage":"activeadmin.info","size":19765,"stargazers_count":5836,"watchers_count":5836,"language":"Ruby","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":2076,"mirror_url":null,"open_issues_count":191,"forks":2076,"open_issues":191,"watchers":5836,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/activeadmin/activeadmin/pulls/3848"},"html":{"href":"https://github.com/activeadmin/activeadmin/pull/3848"},"issue":{"href":"https://api.github.com/repos/activeadmin/activeadmin/issues/3848"},"comments":{"href":"https://api.github.com/repos/activeadmin/activeadmin/issues/3848/comments"},"review_comments":{"href":"https://api.github.com/repos/activeadmin/activeadmin/pulls/3848/comments"},"review_comment":{"href":"https://api.github.com/repos/activeadmin/activeadmin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/activeadmin/activeadmin/pulls/3848/commits"},"statuses":{"href":"https://api.github.com/repos/activeadmin/activeadmin/statuses/6ab8c6592496d272619bcf6e72d170eca660976c"}}}}