{"action":"created","issue":{"url":"https://api.github.com/repos/amatsuda/kaminari/issues/813","repository_url":"https://api.github.com/repos/amatsuda/kaminari","labels_url":"https://api.github.com/repos/amatsuda/kaminari/issues/813/labels{/name}","comments_url":"https://api.github.com/repos/amatsuda/kaminari/issues/813/comments","events_url":"https://api.github.com/repos/amatsuda/kaminari/issues/813/events","html_url":"https://github.com/amatsuda/kaminari/issues/813","id":170239841,"number":813,"title":"page.per producing wrong result set","user":{"login":"dudo","id":2963800,"avatar_url":"https://avatars.githubusercontent.com/u/2963800?v=3","gravatar_id":"","url":"https://api.github.com/users/dudo","html_url":"https://github.com/dudo","followers_url":"https://api.github.com/users/dudo/followers","following_url":"https://api.github.com/users/dudo/following{/other_user}","gists_url":"https://api.github.com/users/dudo/gists{/gist_id}","starred_url":"https://api.github.com/users/dudo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dudo/subscriptions","organizations_url":"https://api.github.com/users/dudo/orgs","repos_url":"https://api.github.com/users/dudo/repos","events_url":"https://api.github.com/users/dudo/events{/privacy}","received_events_url":"https://api.github.com/users/dudo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/amatsuda/kaminari/labels/ActiveRecord","name":"ActiveRecord","color":"d7e102"},{"url":"https://api.github.com/repos/amatsuda/kaminari/labels/Feedback%20Needed","name":"Feedback Needed","color":"03eb31"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-09T18:39:46Z","updated_at":"2016-10-19T03:05:03Z","closed_at":null,"body":"```\r\n[9] pry(#<SmartListing::Base>)> @collection.class\r\n=> Loan::ActiveRecord_Relation\r\n[10] pry(#<SmartListing::Base>)> @collection.size\r\n=> 16\r\n[11] pry(#<SmartListing::Base>)> @page\r\n=> \"\"\r\n[12] pry(#<SmartListing::Base>)> @per_page\r\n=> 10\r\n[13] pry(#<SmartListing::Base>)> @collection.page(@page).per(@per_page).size\r\n2016-08-09 11:33:21,392|54722|DEBUG|development| -   CACHE (0.0ms)  SELECT  DISTINCT `loans`.`id`, statistics.created_at AS alias_0 FROM `loans` LEFT OUTER JOIN `lenders` ON `lenders`.`id` = `loans`.`lender_id` LEFT OUTER JOIN `comments` ON `comments`.`commentable_id` = `loans`.`id` AND `comments`.`commentable_type` = 'Loan' LEFT OUTER JOIN `admins` ON `admins`.`id` = `loans`.`admin_id` LEFT OUTER JOIN `partners` ON `partners`.`id` = `loans`.`partner_id` LEFT OUTER JOIN `promotions` ON `promotions`.`id` = `loans`.`promotion_id` LEFT OUTER JOIN `businesses` ON `businesses`.`loan_id` = `loans`.`id` LEFT OUTER JOIN `users` ON `users`.`id` = `loans`.`user_id` LEFT OUTER JOIN `statistics` ON `statistics`.`loan_id` = `loans`.`id` LEFT OUTER JOIN `decisions` ON `decisions`.`loan_id` = `loans`.`id` WHERE `loans`.`lender_id` IN (6, 2, 3, 5, 1, 4, 7) AND `loans`.`state` = 'funded' AND `lenders`.`info_key` IN ('gpb', 'gpb_large')  ORDER BY statistics.created_at desc LIMIT 10 OFFSET 0  [[\"commentable_type\", \"Loan\"]]\r\n2016-08-09 11:33:21,398|54722|DEBUG|development| -   CACHE (0.0ms)  SELECT DISTINCT COUNT(DISTINCT `loans`.`id`) FROM `loans` LEFT OUTER JOIN `lenders` ON `lenders`.`id` = `loans`.`lender_id` LEFT OUTER JOIN `comments` ON `comments`.`commentable_id` = `loans`.`id` AND `comments`.`commentable_type` = 'Loan' LEFT OUTER JOIN `admins` ON `admins`.`id` = `loans`.`admin_id` LEFT OUTER JOIN `partners` ON `partners`.`id` = `loans`.`partner_id` LEFT OUTER JOIN `promotions` ON `promotions`.`id` = `loans`.`promotion_id` LEFT OUTER JOIN `businesses` ON `businesses`.`loan_id` = `loans`.`id` LEFT OUTER JOIN `users` ON `users`.`id` = `loans`.`user_id` LEFT OUTER JOIN `statistics` ON `statistics`.`loan_id` = `loans`.`id` LEFT OUTER JOIN `decisions` ON `decisions`.`loan_id` = `loans`.`id` WHERE `loans`.`lender_id` IN (6, 2, 3, 5, 1, 4, 7) AND `loans`.`state` = 'funded' AND `lenders`.`info_key` IN ('gpb', 'gpb_large') AND `loans`.`id` IN (124, 20, 9, 653, 1652, 1652, 1652, 1652, 1652, 1652)  [[\"commentable_type\", \"Loan\"]]\r\n=> 5\r\n```\r\n\r\nThe concerning part is this... \r\n\r\n    AND `loans`.`id` IN (124, 20, 9, 653, 1652, 1652, 1652, 1652, 1652, 1652)\r\n\r\n`@collection` is table with a handful of other tables included, and I can't figure out for the life of me why paginating this collection botches the results. This behavior is in the https://github.com/Sology/smart_listing gem, but they use kaminari gem for pagination, so I hope you don't mind me asking this here.\r\n\r\nAny thoughts or ideas on this mystery?"},"comment":{"url":"https://api.github.com/repos/amatsuda/kaminari/issues/comments/254698347","html_url":"https://github.com/amatsuda/kaminari/issues/813#issuecomment-254698347","issue_url":"https://api.github.com/repos/amatsuda/kaminari/issues/813","id":254698347,"user":{"login":"yuki24","id":386234,"avatar_url":"https://avatars.githubusercontent.com/u/386234?v=3","gravatar_id":"","url":"https://api.github.com/users/yuki24","html_url":"https://github.com/yuki24","followers_url":"https://api.github.com/users/yuki24/followers","following_url":"https://api.github.com/users/yuki24/following{/other_user}","gists_url":"https://api.github.com/users/yuki24/gists{/gist_id}","starred_url":"https://api.github.com/users/yuki24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuki24/subscriptions","organizations_url":"https://api.github.com/users/yuki24/orgs","repos_url":"https://api.github.com/users/yuki24/repos","events_url":"https://api.github.com/users/yuki24/events{/privacy}","received_events_url":"https://api.github.com/users/yuki24/received_events","type":"User","site_admin":false},"created_at":"2016-10-19T03:05:03Z","updated_at":"2016-10-19T03:05:03Z","body":"@chrise86 Thanks for the info. This is really helpful. Could you also tell us the numbers of event/performance records in the DB, the number of the elements you would expect to see on a page and the number of elements you actually saw?"}}
{"actor":{"display_login":"yuki24"}}