{"action":"created","comment":{"url":"https://api.github.com/repos/mdsol/pagem/pulls/comments/46204791","id":46204791,"diff_hunk":"@@ -98,3 +98,45 @@ def onkeypress_script\n     \"if(event.keyCode == 13) Pager.setPage(this, '#{@page_variable}', this.value, #{@is_remote});\"\n   end\n end\n+\n+# PagemMultiscope class inherits from Pagem and allows pagination of 2 scopes, returning either the paginated\n+# set of the first scope with limit and offset, the paginated set of the second scope with limit and offset,\n+# or results of a combined scope proc combining both scopes if the page is rendering a combination\n+# of both table records on the same page\n+# TODO Move this back to the Pagem class and extend it to allow more than 2 scopes\n+class PagemMultiscope < Pagem\n+  def initialize(first_scope, second_scope, params, opt = {})\n+    super(first_scope, params, opt)\n+    @first_scope, @second_scope = first_scope, second_scope\n+    @first_scope_count, @second_scope_count = first_scope.count, second_scope.count\n+    @count = @first_scope_count + @second_scope_count","path":"lib/pagem.rb","position":15,"original_position":15,"commit_id":"d486da1d35554731ccd597869794415c9bcc4583","original_commit_id":"d486da1d35554731ccd597869794415c9bcc4583","user":{"login":"mahmed-mdsol","id":1247607,"avatar_url":"https://avatars.githubusercontent.com/u/1247607?v=3","gravatar_id":"","url":"https://api.github.com/users/mahmed-mdsol","html_url":"https://github.com/mahmed-mdsol","followers_url":"https://api.github.com/users/mahmed-mdsol/followers","following_url":"https://api.github.com/users/mahmed-mdsol/following{/other_user}","gists_url":"https://api.github.com/users/mahmed-mdsol/gists{/gist_id}","starred_url":"https://api.github.com/users/mahmed-mdsol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mahmed-mdsol/subscriptions","organizations_url":"https://api.github.com/users/mahmed-mdsol/orgs","repos_url":"https://api.github.com/users/mahmed-mdsol/repos","events_url":"https://api.github.com/users/mahmed-mdsol/events{/privacy}","received_events_url":"https://api.github.com/users/mahmed-mdsol/received_events","type":"User","site_admin":false},"body":"I imagine things would break here if either scope is using a GROUP by (since group.count will return a hash instead of numbers you can add together). Maybe we should add some protection for that? I think the Pagem class gets around it by allowing users to pass in a count_number option. Maybe we can do the same here just so it's a bit more flexible?","created_at":"2015-11-30T21:15:56Z","updated_at":"2015-11-30T21:15:56Z","html_url":"https://github.com/mdsol/pagem/pull/4#discussion_r46204791","pull_request_url":"https://api.github.com/repos/mdsol/pagem/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/mdsol/pagem/pulls/comments/46204791"},"html":{"href":"https://github.com/mdsol/pagem/pull/4#discussion_r46204791"},"pull_request":{"href":"https://api.github.com/repos/mdsol/pagem/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/mdsol/pagem/pulls/4","id":52169260,"html_url":"https://github.com/mdsol/pagem/pull/4","diff_url":"https://github.com/mdsol/pagem/pull/4.diff","patch_url":"https://github.com/mdsol/pagem/pull/4.patch","issue_url":"https://api.github.com/repos/mdsol/pagem/issues/4","number":4,"state":"open","locked":false,"title":"Modified Pagem module to include inner class to support pagination of…","user":{"login":"yzhangmedidata","id":1162606,"avatar_url":"https://avatars.githubusercontent.com/u/1162606?v=3","gravatar_id":"","url":"https://api.github.com/users/yzhangmedidata","html_url":"https://github.com/yzhangmedidata","followers_url":"https://api.github.com/users/yzhangmedidata/followers","following_url":"https://api.github.com/users/yzhangmedidata/following{/other_user}","gists_url":"https://api.github.com/users/yzhangmedidata/gists{/gist_id}","starred_url":"https://api.github.com/users/yzhangmedidata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yzhangmedidata/subscriptions","organizations_url":"https://api.github.com/users/yzhangmedidata/orgs","repos_url":"https://api.github.com/users/yzhangmedidata/repos","events_url":"https://api.github.com/users/yzhangmedidata/events{/privacy}","received_events_url":"https://api.github.com/users/yzhangmedidata/received_events","type":"User","site_admin":false},"body":"… 2 different scopes using a combining proc\r\n\r\nThis is a necessary feature for Balance on the inventory items page to allow for breaking the combined union scope which can take an extremely long amount of time, this adds an inheriting module to allow multiple scopes to be passed in and paginated, so that combining scopes is only necessary on a single page where the 2 scopes are joined","created_at":"2015-11-30T19:42:42Z","updated_at":"2015-11-30T21:15:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f88c7876e890d54e3d383b3bf149e20a0036dc8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mdsol/pagem/pulls/4/commits","review_comments_url":"https://api.github.com/repos/mdsol/pagem/pulls/4/comments","review_comment_url":"https://api.github.com/repos/mdsol/pagem/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mdsol/pagem/issues/4/comments","statuses_url":"https://api.github.com/repos/mdsol/pagem/statuses/d486da1d35554731ccd597869794415c9bcc4583","head":{"label":"mdsol:multiscope","ref":"multiscope","sha":"d486da1d35554731ccd597869794415c9bcc4583","user":{"login":"mdsol","id":171103,"avatar_url":"https://avatars.githubusercontent.com/u/171103?v=3","gravatar_id":"","url":"https://api.github.com/users/mdsol","html_url":"https://github.com/mdsol","followers_url":"https://api.github.com/users/mdsol/followers","following_url":"https://api.github.com/users/mdsol/following{/other_user}","gists_url":"https://api.github.com/users/mdsol/gists{/gist_id}","starred_url":"https://api.github.com/users/mdsol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdsol/subscriptions","organizations_url":"https://api.github.com/users/mdsol/orgs","repos_url":"https://api.github.com/users/mdsol/repos","events_url":"https://api.github.com/users/mdsol/events{/privacy}","received_events_url":"https://api.github.com/users/mdsol/received_events","type":"Organization","site_admin":false},"repo":{"id":803773,"name":"pagem","full_name":"mdsol/pagem","owner":{"login":"mdsol","id":171103,"avatar_url":"https://avatars.githubusercontent.com/u/171103?v=3","gravatar_id":"","url":"https://api.github.com/users/mdsol","html_url":"https://github.com/mdsol","followers_url":"https://api.github.com/users/mdsol/followers","following_url":"https://api.github.com/users/mdsol/following{/other_user}","gists_url":"https://api.github.com/users/mdsol/gists{/gist_id}","starred_url":"https://api.github.com/users/mdsol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdsol/subscriptions","organizations_url":"https://api.github.com/users/mdsol/orgs","repos_url":"https://api.github.com/users/mdsol/repos","events_url":"https://api.github.com/users/mdsol/events{/privacy}","received_events_url":"https://api.github.com/users/mdsol/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mdsol/pagem","description":"Pagination library for Mdsol Rails applications","fork":false,"url":"https://api.github.com/repos/mdsol/pagem","forks_url":"https://api.github.com/repos/mdsol/pagem/forks","keys_url":"https://api.github.com/repos/mdsol/pagem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mdsol/pagem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mdsol/pagem/teams","hooks_url":"https://api.github.com/repos/mdsol/pagem/hooks","issue_events_url":"https://api.github.com/repos/mdsol/pagem/issues/events{/number}","events_url":"https://api.github.com/repos/mdsol/pagem/events","assignees_url":"https://api.github.com/repos/mdsol/pagem/assignees{/user}","branches_url":"https://api.github.com/repos/mdsol/pagem/branches{/branch}","tags_url":"https://api.github.com/repos/mdsol/pagem/tags","blobs_url":"https://api.github.com/repos/mdsol/pagem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mdsol/pagem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mdsol/pagem/git/refs{/sha}","trees_url":"https://api.github.com/repos/mdsol/pagem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mdsol/pagem/statuses/{sha}","languages_url":"https://api.github.com/repos/mdsol/pagem/languages","stargazers_url":"https://api.github.com/repos/mdsol/pagem/stargazers","contributors_url":"https://api.github.com/repos/mdsol/pagem/contributors","subscribers_url":"https://api.github.com/repos/mdsol/pagem/subscribers","subscription_url":"https://api.github.com/repos/mdsol/pagem/subscription","commits_url":"https://api.github.com/repos/mdsol/pagem/commits{/sha}","git_commits_url":"https://api.github.com/repos/mdsol/pagem/git/commits{/sha}","comments_url":"https://api.github.com/repos/mdsol/pagem/comments{/number}","issue_comment_url":"https://api.github.com/repos/mdsol/pagem/issues/comments{/number}","contents_url":"https://api.github.com/repos/mdsol/pagem/contents/{+path}","compare_url":"https://api.github.com/repos/mdsol/pagem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mdsol/pagem/merges","archive_url":"https://api.github.com/repos/mdsol/pagem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mdsol/pagem/downloads","issues_url":"https://api.github.com/repos/mdsol/pagem/issues{/number}","pulls_url":"https://api.github.com/repos/mdsol/pagem/pulls{/number}","milestones_url":"https://api.github.com/repos/mdsol/pagem/milestones{/number}","notifications_url":"https://api.github.com/repos/mdsol/pagem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mdsol/pagem/labels{/name}","releases_url":"https://api.github.com/repos/mdsol/pagem/releases{/id}","created_at":"2010-07-28T20:43:13Z","updated_at":"2015-01-12T22:33:58Z","pushed_at":"2015-11-30T19:49:53Z","git_url":"git://github.com/mdsol/pagem.git","ssh_url":"git@github.com:mdsol/pagem.git","clone_url":"https://github.com/mdsol/pagem.git","svn_url":"https://github.com/mdsol/pagem","homepage":"","size":56,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"mdsol:master","ref":"master","sha":"3167fca5fd522e56fdf2186937fa63bd289738f6","user":{"login":"mdsol","id":171103,"avatar_url":"https://avatars.githubusercontent.com/u/171103?v=3","gravatar_id":"","url":"https://api.github.com/users/mdsol","html_url":"https://github.com/mdsol","followers_url":"https://api.github.com/users/mdsol/followers","following_url":"https://api.github.com/users/mdsol/following{/other_user}","gists_url":"https://api.github.com/users/mdsol/gists{/gist_id}","starred_url":"https://api.github.com/users/mdsol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdsol/subscriptions","organizations_url":"https://api.github.com/users/mdsol/orgs","repos_url":"https://api.github.com/users/mdsol/repos","events_url":"https://api.github.com/users/mdsol/events{/privacy}","received_events_url":"https://api.github.com/users/mdsol/received_events","type":"Organization","site_admin":false},"repo":{"id":803773,"name":"pagem","full_name":"mdsol/pagem","owner":{"login":"mdsol","id":171103,"avatar_url":"https://avatars.githubusercontent.com/u/171103?v=3","gravatar_id":"","url":"https://api.github.com/users/mdsol","html_url":"https://github.com/mdsol","followers_url":"https://api.github.com/users/mdsol/followers","following_url":"https://api.github.com/users/mdsol/following{/other_user}","gists_url":"https://api.github.com/users/mdsol/gists{/gist_id}","starred_url":"https://api.github.com/users/mdsol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdsol/subscriptions","organizations_url":"https://api.github.com/users/mdsol/orgs","repos_url":"https://api.github.com/users/mdsol/repos","events_url":"https://api.github.com/users/mdsol/events{/privacy}","received_events_url":"https://api.github.com/users/mdsol/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mdsol/pagem","description":"Pagination library for Mdsol Rails applications","fork":false,"url":"https://api.github.com/repos/mdsol/pagem","forks_url":"https://api.github.com/repos/mdsol/pagem/forks","keys_url":"https://api.github.com/repos/mdsol/pagem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mdsol/pagem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mdsol/pagem/teams","hooks_url":"https://api.github.com/repos/mdsol/pagem/hooks","issue_events_url":"https://api.github.com/repos/mdsol/pagem/issues/events{/number}","events_url":"https://api.github.com/repos/mdsol/pagem/events","assignees_url":"https://api.github.com/repos/mdsol/pagem/assignees{/user}","branches_url":"https://api.github.com/repos/mdsol/pagem/branches{/branch}","tags_url":"https://api.github.com/repos/mdsol/pagem/tags","blobs_url":"https://api.github.com/repos/mdsol/pagem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mdsol/pagem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mdsol/pagem/git/refs{/sha}","trees_url":"https://api.github.com/repos/mdsol/pagem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mdsol/pagem/statuses/{sha}","languages_url":"https://api.github.com/repos/mdsol/pagem/languages","stargazers_url":"https://api.github.com/repos/mdsol/pagem/stargazers","contributors_url":"https://api.github.com/repos/mdsol/pagem/contributors","subscribers_url":"https://api.github.com/repos/mdsol/pagem/subscribers","subscription_url":"https://api.github.com/repos/mdsol/pagem/subscription","commits_url":"https://api.github.com/repos/mdsol/pagem/commits{/sha}","git_commits_url":"https://api.github.com/repos/mdsol/pagem/git/commits{/sha}","comments_url":"https://api.github.com/repos/mdsol/pagem/comments{/number}","issue_comment_url":"https://api.github.com/repos/mdsol/pagem/issues/comments{/number}","contents_url":"https://api.github.com/repos/mdsol/pagem/contents/{+path}","compare_url":"https://api.github.com/repos/mdsol/pagem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mdsol/pagem/merges","archive_url":"https://api.github.com/repos/mdsol/pagem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mdsol/pagem/downloads","issues_url":"https://api.github.com/repos/mdsol/pagem/issues{/number}","pulls_url":"https://api.github.com/repos/mdsol/pagem/pulls{/number}","milestones_url":"https://api.github.com/repos/mdsol/pagem/milestones{/number}","notifications_url":"https://api.github.com/repos/mdsol/pagem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mdsol/pagem/labels{/name}","releases_url":"https://api.github.com/repos/mdsol/pagem/releases{/id}","created_at":"2010-07-28T20:43:13Z","updated_at":"2015-01-12T22:33:58Z","pushed_at":"2015-11-30T19:49:53Z","git_url":"git://github.com/mdsol/pagem.git","ssh_url":"git@github.com:mdsol/pagem.git","clone_url":"https://github.com/mdsol/pagem.git","svn_url":"https://github.com/mdsol/pagem","homepage":"","size":56,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mdsol/pagem/pulls/4"},"html":{"href":"https://github.com/mdsol/pagem/pull/4"},"issue":{"href":"https://api.github.com/repos/mdsol/pagem/issues/4"},"comments":{"href":"https://api.github.com/repos/mdsol/pagem/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/mdsol/pagem/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/mdsol/pagem/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mdsol/pagem/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/mdsol/pagem/statuses/d486da1d35554731ccd597869794415c9bcc4583"}}}}