{"action":"opened","number":78,"pull_request":{"url":"https://api.github.com/repos/redding/ardb/pulls/78","id":53170202,"html_url":"https://github.com/redding/ardb/pull/78","diff_url":"https://github.com/redding/ardb/pull/78.diff","patch_url":"https://github.com/redding/ardb/pull/78.patch","issue_url":"https://api.github.com/repos/redding/ardb/issues/78","number":78,"state":"open","locked":false,"title":"Add `DefaultOrderBy` mixin","user":{"login":"jcredding","id":85966,"avatar_url":"https://avatars.githubusercontent.com/u/85966?v=3","gravatar_id":"","url":"https://api.github.com/users/jcredding","html_url":"https://github.com/jcredding","followers_url":"https://api.github.com/users/jcredding/followers","following_url":"https://api.github.com/users/jcredding/following{/other_user}","gists_url":"https://api.github.com/users/jcredding/gists{/gist_id}","starred_url":"https://api.github.com/users/jcredding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcredding/subscriptions","organizations_url":"https://api.github.com/users/jcredding/orgs","repos_url":"https://api.github.com/users/jcredding/repos","events_url":"https://api.github.com/users/jcredding/events{/privacy}","received_events_url":"https://api.github.com/users/jcredding/received_events","type":"User","site_admin":false},"body":"This adds a default order by mixin that provides the logic for\r\nautomatically defaulting a record to the next available \"order-by\"\r\nvalue. This is intended to make it simple to easy order a set of\r\nrecords when they are initially created.\r\n\r\nThe mixin adds a before validation callback that will run a query\r\nto check for the current max order by value in the DB. It will then\r\nset its order by value to the current max + 1. This makes records\r\norder by default in the order they are created.\r\n\r\nThe mixin also allows providing a custom scope proc. This will be\r\nused when determining the current max order by value. This can be\r\nused to group or scope order by values. For example, if all the\r\nrecords have a grouping and each grouping of records should be\r\nordered separately then the scope can be used to scope the current\r\nmax using the records grouping.\r\n\r\nThe mixin only sets the order by before validation on create when\r\nit hasn't been given a custom value. The order by can be reset to\r\nthe next highest value at anytime though by calling the\r\n`reset_order_by` method. This can be used with callbacks to reset\r\na records order by when an attribute changes and, for example, it\r\nswitches from one grouping to another.\r\n\r\n@kellyredding - FYI. We already discussed this change in #77. This just points it to a feature branch instead of master.","created_at":"2015-12-09T20:03:50Z","updated_at":"2015-12-09T20:03:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/redding/ardb/pulls/78/commits","review_comments_url":"https://api.github.com/repos/redding/ardb/pulls/78/comments","review_comment_url":"https://api.github.com/repos/redding/ardb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/redding/ardb/issues/78/comments","statuses_url":"https://api.github.com/repos/redding/ardb/statuses/5ccff77ab5e92ccf1fab32eb7a1cbdfef2ece9b2","head":{"label":"redding:jcr-default-order-by","ref":"jcr-default-order-by","sha":"5ccff77ab5e92ccf1fab32eb7a1cbdfef2ece9b2","user":{"login":"redding","id":2427810,"avatar_url":"https://avatars.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"repo":{"id":9097854,"name":"ardb","full_name":"redding/ardb","owner":{"login":"redding","id":2427810,"avatar_url":"https://avatars.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/redding/ardb","description":"Activerecord database tools.","fork":false,"url":"https://api.github.com/repos/redding/ardb","forks_url":"https://api.github.com/repos/redding/ardb/forks","keys_url":"https://api.github.com/repos/redding/ardb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/redding/ardb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/redding/ardb/teams","hooks_url":"https://api.github.com/repos/redding/ardb/hooks","issue_events_url":"https://api.github.com/repos/redding/ardb/issues/events{/number}","events_url":"https://api.github.com/repos/redding/ardb/events","assignees_url":"https://api.github.com/repos/redding/ardb/assignees{/user}","branches_url":"https://api.github.com/repos/redding/ardb/branches{/branch}","tags_url":"https://api.github.com/repos/redding/ardb/tags","blobs_url":"https://api.github.com/repos/redding/ardb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/redding/ardb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/redding/ardb/git/refs{/sha}","trees_url":"https://api.github.com/repos/redding/ardb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/redding/ardb/statuses/{sha}","languages_url":"https://api.github.com/repos/redding/ardb/languages","stargazers_url":"https://api.github.com/repos/redding/ardb/stargazers","contributors_url":"https://api.github.com/repos/redding/ardb/contributors","subscribers_url":"https://api.github.com/repos/redding/ardb/subscribers","subscription_url":"https://api.github.com/repos/redding/ardb/subscription","commits_url":"https://api.github.com/repos/redding/ardb/commits{/sha}","git_commits_url":"https://api.github.com/repos/redding/ardb/git/commits{/sha}","comments_url":"https://api.github.com/repos/redding/ardb/comments{/number}","issue_comment_url":"https://api.github.com/repos/redding/ardb/issues/comments{/number}","contents_url":"https://api.github.com/repos/redding/ardb/contents/{+path}","compare_url":"https://api.github.com/repos/redding/ardb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/redding/ardb/merges","archive_url":"https://api.github.com/repos/redding/ardb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/redding/ardb/downloads","issues_url":"https://api.github.com/repos/redding/ardb/issues{/number}","pulls_url":"https://api.github.com/repos/redding/ardb/pulls{/number}","milestones_url":"https://api.github.com/repos/redding/ardb/milestones{/number}","notifications_url":"https://api.github.com/repos/redding/ardb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/redding/ardb/labels{/name}","releases_url":"https://api.github.com/repos/redding/ardb/releases{/id}","created_at":"2013-03-29T12:18:17Z","updated_at":"2015-07-08T19:48:26Z","pushed_at":"2015-12-09T20:03:50Z","git_url":"git://github.com/redding/ardb.git","ssh_url":"git@github.com:redding/ardb.git","clone_url":"https://github.com/redding/ardb.git","svn_url":"https://github.com/redding/ardb","homepage":null,"size":152,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":2,"default_branch":"master"}},"base":{"label":"redding:jcr-feature-additions","ref":"jcr-feature-additions","sha":"3d021214d9e435a758dd8bd3cb4168a93acdc5ca","user":{"login":"redding","id":2427810,"avatar_url":"https://avatars.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"repo":{"id":9097854,"name":"ardb","full_name":"redding/ardb","owner":{"login":"redding","id":2427810,"avatar_url":"https://avatars.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/redding/ardb","description":"Activerecord database tools.","fork":false,"url":"https://api.github.com/repos/redding/ardb","forks_url":"https://api.github.com/repos/redding/ardb/forks","keys_url":"https://api.github.com/repos/redding/ardb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/redding/ardb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/redding/ardb/teams","hooks_url":"https://api.github.com/repos/redding/ardb/hooks","issue_events_url":"https://api.github.com/repos/redding/ardb/issues/events{/number}","events_url":"https://api.github.com/repos/redding/ardb/events","assignees_url":"https://api.github.com/repos/redding/ardb/assignees{/user}","branches_url":"https://api.github.com/repos/redding/ardb/branches{/branch}","tags_url":"https://api.github.com/repos/redding/ardb/tags","blobs_url":"https://api.github.com/repos/redding/ardb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/redding/ardb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/redding/ardb/git/refs{/sha}","trees_url":"https://api.github.com/repos/redding/ardb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/redding/ardb/statuses/{sha}","languages_url":"https://api.github.com/repos/redding/ardb/languages","stargazers_url":"https://api.github.com/repos/redding/ardb/stargazers","contributors_url":"https://api.github.com/repos/redding/ardb/contributors","subscribers_url":"https://api.github.com/repos/redding/ardb/subscribers","subscription_url":"https://api.github.com/repos/redding/ardb/subscription","commits_url":"https://api.github.com/repos/redding/ardb/commits{/sha}","git_commits_url":"https://api.github.com/repos/redding/ardb/git/commits{/sha}","comments_url":"https://api.github.com/repos/redding/ardb/comments{/number}","issue_comment_url":"https://api.github.com/repos/redding/ardb/issues/comments{/number}","contents_url":"https://api.github.com/repos/redding/ardb/contents/{+path}","compare_url":"https://api.github.com/repos/redding/ardb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/redding/ardb/merges","archive_url":"https://api.github.com/repos/redding/ardb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/redding/ardb/downloads","issues_url":"https://api.github.com/repos/redding/ardb/issues{/number}","pulls_url":"https://api.github.com/repos/redding/ardb/pulls{/number}","milestones_url":"https://api.github.com/repos/redding/ardb/milestones{/number}","notifications_url":"https://api.github.com/repos/redding/ardb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/redding/ardb/labels{/name}","releases_url":"https://api.github.com/repos/redding/ardb/releases{/id}","created_at":"2013-03-29T12:18:17Z","updated_at":"2015-07-08T19:48:26Z","pushed_at":"2015-12-09T20:03:50Z","git_url":"git://github.com/redding/ardb.git","ssh_url":"git@github.com:redding/ardb.git","clone_url":"https://github.com/redding/ardb.git","svn_url":"https://github.com/redding/ardb","homepage":null,"size":152,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/redding/ardb/pulls/78"},"html":{"href":"https://github.com/redding/ardb/pull/78"},"issue":{"href":"https://api.github.com/repos/redding/ardb/issues/78"},"comments":{"href":"https://api.github.com/repos/redding/ardb/issues/78/comments"},"review_comments":{"href":"https://api.github.com/repos/redding/ardb/pulls/78/comments"},"review_comment":{"href":"https://api.github.com/repos/redding/ardb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/redding/ardb/pulls/78/commits"},"statuses":{"href":"https://api.github.com/repos/redding/ardb/statuses/5ccff77ab5e92ccf1fab32eb7a1cbdfef2ece9b2"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":190,"deletions":2,"changed_files":4}}