{"action":"created","comment":{"url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/comments/102820059","pull_request_review_id":23589101,"id":102820059,"diff_hunk":"@@ -2,13 +2,26 @@\n module V0\n   class ApiController < ApplicationController\n     skip_before_action :authenticate_user!\n+    before_action :resolve_version\n \n     def cors_preflight\n       head(:ok)\n     end\n \n     private\n \n+    # Newest production data version assumed when version param is undefined\n+    def resolve_version\n+      v = params[:version]\n+      version = v.present? ? Version.find_by(number: v) : Version.default_version\n+      raise ActiveRecord::RecordNotFound, \"Version #{v} not found\" unless version.try(:number)","path":"app/controllers/v0/api_controller.rb","position":16,"original_position":16,"commit_id":"35129b750a843b12b76bd8767d2375bd9cfa9a75","original_commit_id":"35129b750a843b12b76bd8767d2375bd9cfa9a75","user":{"login":"patrickvinograd","id":20694532,"avatar_url":"https://avatars.githubusercontent.com/u/20694532?v=3","gravatar_id":"","url":"https://api.github.com/users/patrickvinograd","html_url":"https://github.com/patrickvinograd","followers_url":"https://api.github.com/users/patrickvinograd/followers","following_url":"https://api.github.com/users/patrickvinograd/following{/other_user}","gists_url":"https://api.github.com/users/patrickvinograd/gists{/gist_id}","starred_url":"https://api.github.com/users/patrickvinograd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrickvinograd/subscriptions","organizations_url":"https://api.github.com/users/patrickvinograd/orgs","repos_url":"https://api.github.com/users/patrickvinograd/repos","events_url":"https://api.github.com/users/patrickvinograd/events{/privacy}","received_events_url":"https://api.github.com/users/patrickvinograd/received_events","type":"User","site_admin":false},"body":"This might be better as a Common::Exceptions::RecordNotFound, or even better Common::Exceptions::InvalidFieldValue since it's a parameter that can't be found as opposed to a top-level resource.","created_at":"2017-02-23T21:17:17Z","updated_at":"2017-02-23T21:19:06Z","html_url":"https://github.com/department-of-veterans-affairs/gibct-data-service/pull/206#discussion_r102820059","pull_request_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/206","_links":{"self":{"href":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/comments/102820059"},"html":{"href":"https://github.com/department-of-veterans-affairs/gibct-data-service/pull/206#discussion_r102820059"},"pull_request":{"href":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/206"}}},"pull_request":{"url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/206","id":107515508,"html_url":"https://github.com/department-of-veterans-affairs/gibct-data-service/pull/206","diff_url":"https://github.com/department-of-veterans-affairs/gibct-data-service/pull/206.diff","patch_url":"https://github.com/department-of-veterans-affairs/gibct-data-service/pull/206.patch","issue_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/issues/206","number":206,"state":"open","locked":false,"title":"Facet counts and other suboptimal enhancements","user":{"login":"ben-USDS-damman","id":25037543,"avatar_url":"https://avatars.githubusercontent.com/u/25037543?v=3","gravatar_id":"","url":"https://api.github.com/users/ben-USDS-damman","html_url":"https://github.com/ben-USDS-damman","followers_url":"https://api.github.com/users/ben-USDS-damman/followers","following_url":"https://api.github.com/users/ben-USDS-damman/following{/other_user}","gists_url":"https://api.github.com/users/ben-USDS-damman/gists{/gist_id}","starred_url":"https://api.github.com/users/ben-USDS-damman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben-USDS-damman/subscriptions","organizations_url":"https://api.github.com/users/ben-USDS-damman/orgs","repos_url":"https://api.github.com/users/ben-USDS-damman/repos","events_url":"https://api.github.com/users/ben-USDS-damman/events{/privacy}","received_events_url":"https://api.github.com/users/ben-USDS-damman/received_events","type":"User","site_admin":false},"body":"Wherein all API responses return verbose data versioning metadata.\r\n```json\r\n...\r\n\"meta\": {\r\n  \"version\": {\r\n    \"number\": 1,\r\n    \"created_at\": \"2017-02-16T05:23:49.937Z\",\r\n    \"preview\": false\r\n  }\r\n}\r\n```\r\n\r\nAnd search results include filter counts to support the search interface.\r\n```json\r\n...\r\n\"facets\": {\r\n  \"type\": {\r\n    \"school\": 3,\r\n    \"employer\": 0\r\n  },\r\n  \"type_name\": {\r\n    \"for profit\": 2,\r\n    \"public\": 1\r\n  },\r\n  \"state\": {\r\n    \"ga\": 1,\r\n    \"mn\": 2\r\n  },\r\n  \"country\": {\r\n     \"usa\": 3\r\n  },\r\n  \"caution_flag\": {\r\n    \"true\": 3\r\n  },\r\n  \"student_vet_group\": {\r\n    \"false\": 3\r\n  },\r\n  \"yellow_ribbon_scholarship\": {\r\n    \"false\": 3\r\n  },\r\n  \"principles_of_excellence\": {\r\n    \"false\": 1,\r\n    \"true\": 2\r\n  },\r\n  \"eight_keys_to_veteran_success\": {\r\n    \"false\": 3\r\n  }\r\n}\r\n```\r\n\r\nUpon further reflection the facet objects should probably be arrays.","created_at":"2017-02-22T22:39:28Z","updated_at":"2017-02-23T21:19:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5c1267085e9a5615f5157a017872dd029815b9e4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/206/commits","review_comments_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/206/comments","review_comment_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/issues/206/comments","statuses_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/statuses/35129b750a843b12b76bd8767d2375bd9cfa9a75","head":{"label":"department-of-veterans-affairs:v2-with-facets","ref":"v2-with-facets","sha":"35129b750a843b12b76bd8767d2375bd9cfa9a75","user":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars.githubusercontent.com/u/5421563?v=3","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"repo":{"id":52401729,"name":"gibct-data-service","full_name":"department-of-veterans-affairs/gibct-data-service","owner":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars.githubusercontent.com/u/5421563?v=3","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/department-of-veterans-affairs/gibct-data-service","description":"Allows stakeholders to build a valid GIBCT database from various data sources and apis.","fork":false,"url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service","forks_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/forks","keys_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/teams","hooks_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/hooks","issue_events_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/issues/events{/number}","events_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/events","assignees_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/assignees{/user}","branches_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/branches{/branch}","tags_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/tags","blobs_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/statuses/{sha}","languages_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/languages","stargazers_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/stargazers","contributors_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/contributors","subscribers_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/subscribers","subscription_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/subscription","commits_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/contents/{+path}","compare_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/merges","archive_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/downloads","issues_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/issues{/number}","pulls_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls{/number}","milestones_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/milestones{/number}","notifications_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/labels{/name}","releases_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/releases{/id}","deployments_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/deployments","created_at":"2016-02-24T00:24:29Z","updated_at":"2017-02-01T00:47:34Z","pushed_at":"2017-02-23T18:20:02Z","git_url":"git://github.com/department-of-veterans-affairs/gibct-data-service.git","ssh_url":"git@github.com:department-of-veterans-affairs/gibct-data-service.git","clone_url":"https://github.com/department-of-veterans-affairs/gibct-data-service.git","svn_url":"https://github.com/department-of-veterans-affairs/gibct-data-service","homepage":null,"size":31437,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":7,"forks":2,"open_issues":7,"watchers":2,"default_branch":"master"}},"base":{"label":"department-of-veterans-affairs:v2-refactor","ref":"v2-refactor","sha":"19506638d6008367007d9b83cb68828a47c23cd5","user":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars.githubusercontent.com/u/5421563?v=3","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"repo":{"id":52401729,"name":"gibct-data-service","full_name":"department-of-veterans-affairs/gibct-data-service","owner":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars.githubusercontent.com/u/5421563?v=3","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/department-of-veterans-affairs/gibct-data-service","description":"Allows stakeholders to build a valid GIBCT database from various data sources and apis.","fork":false,"url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service","forks_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/forks","keys_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/teams","hooks_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/hooks","issue_events_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/issues/events{/number}","events_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/events","assignees_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/assignees{/user}","branches_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/branches{/branch}","tags_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/tags","blobs_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/statuses/{sha}","languages_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/languages","stargazers_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/stargazers","contributors_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/contributors","subscribers_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/subscribers","subscription_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/subscription","commits_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/contents/{+path}","compare_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/merges","archive_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/downloads","issues_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/issues{/number}","pulls_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls{/number}","milestones_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/milestones{/number}","notifications_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/labels{/name}","releases_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/releases{/id}","deployments_url":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/deployments","created_at":"2016-02-24T00:24:29Z","updated_at":"2017-02-01T00:47:34Z","pushed_at":"2017-02-23T18:20:02Z","git_url":"git://github.com/department-of-veterans-affairs/gibct-data-service.git","ssh_url":"git@github.com:department-of-veterans-affairs/gibct-data-service.git","clone_url":"https://github.com/department-of-veterans-affairs/gibct-data-service.git","svn_url":"https://github.com/department-of-veterans-affairs/gibct-data-service","homepage":null,"size":31437,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":7,"forks":2,"open_issues":7,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/206"},"html":{"href":"https://github.com/department-of-veterans-affairs/gibct-data-service/pull/206"},"issue":{"href":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/issues/206"},"comments":{"href":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/issues/206/comments"},"review_comments":{"href":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/206/comments"},"review_comment":{"href":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/pulls/206/commits"},"statuses":{"href":"https://api.github.com/repos/department-of-veterans-affairs/gibct-data-service/statuses/35129b750a843b12b76bd8767d2375bd9cfa9a75"}}}}
{"actor":{"display_login":"patrickvinograd"}}