{"action":"created","comment":{"url":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/comments/173579615","pull_request_review_id":102803270,"id":173579615,"diff_hunk":"@@ -0,0 +1,41 @@\n+const logger = require('../../logger')('users route get');\n+const defaultApdModel = require('../../db').models.apd;\n+const defaultUserModel = require('../../db').models.user;\n+const loggedIn = require('../../auth/middleware').loggedIn;\n+\n+module.exports = (\n+  app,\n+  ApdModel = defaultApdModel,\n+  UserModel = defaultUserModel\n+) => {\n+  logger.silly('setting up GET /apds route');\n+\n+  app.get('/apds', loggedIn, async (req, res) => {\n+    logger.silly(req, 'handling GET /apds');\n+\n+    try {\n+      // TODO: we should have a helper method that fetches\n+      // and returns state/stateId given userId\n+      const user = await UserModel.where({ id: req.user.id }).fetch({\n+        withRelated: ['state']\n+      });\n+      const state = user.related('state');\n+      const stateId = state.get('id');\n+\n+      if (!stateId) {\n+        logger.verbose('user does not have an associated state');\n+        return res.status(401).end();\n+      }\n+\n+      const whereCondits = { state_id: stateId };\n+      const apds = (await ApdModel.where(whereCondits).fetchAll()).toJSON();","path":"api/routes/apds/get.js","position":31,"original_position":31,"commit_id":"945899b77655d0e95dad3086316d1502670fea92","original_commit_id":"945899b77655d0e95dad3086316d1502670fea92","user":{"login":"brendansudol","id":1060893,"avatar_url":"https://avatars2.githubusercontent.com/u/1060893?v=4","gravatar_id":"","url":"https://api.github.com/users/brendansudol","html_url":"https://github.com/brendansudol","followers_url":"https://api.github.com/users/brendansudol/followers","following_url":"https://api.github.com/users/brendansudol/following{/other_user}","gists_url":"https://api.github.com/users/brendansudol/gists{/gist_id}","starred_url":"https://api.github.com/users/brendansudol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendansudol/subscriptions","organizations_url":"https://api.github.com/users/brendansudol/orgs","repos_url":"https://api.github.com/users/brendansudol/repos","events_url":"https://api.github.com/users/brendansudol/events{/privacy}","received_events_url":"https://api.github.com/users/brendansudol/received_events","type":"User","site_admin":false},"body":"yeah, nothing worried me in this table (at this time), but perhaps we always want to be explicit","created_at":"2018-03-09T22:01:13Z","updated_at":"2018-03-09T22:01:13Z","html_url":"https://github.com/18F/cms-hitech-apd/pull/293#discussion_r173579615","pull_request_url":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/293","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/comments/173579615"},"html":{"href":"https://github.com/18F/cms-hitech-apd/pull/293#discussion_r173579615"},"pull_request":{"href":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/293"}},"in_reply_to_id":173508025},"pull_request":{"url":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/293","id":174035856,"html_url":"https://github.com/18F/cms-hitech-apd/pull/293","diff_url":"https://github.com/18F/cms-hitech-apd/pull/293.diff","patch_url":"https://github.com/18F/cms-hitech-apd/pull/293.patch","issue_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/293","number":293,"state":"open","locked":false,"title":"start APD endpoints","user":{"login":"brendansudol","id":1060893,"avatar_url":"https://avatars2.githubusercontent.com/u/1060893?v=4","gravatar_id":"","url":"https://api.github.com/users/brendansudol","html_url":"https://github.com/brendansudol","followers_url":"https://api.github.com/users/brendansudol/followers","following_url":"https://api.github.com/users/brendansudol/following{/other_user}","gists_url":"https://api.github.com/users/brendansudol/gists{/gist_id}","starred_url":"https://api.github.com/users/brendansudol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendansudol/subscriptions","organizations_url":"https://api.github.com/users/brendansudol/orgs","repos_url":"https://api.github.com/users/brendansudol/repos","events_url":"https://api.github.com/users/brendansudol/events{/privacy}","received_events_url":"https://api.github.com/users/brendansudol/received_events","type":"User","site_admin":false},"body":"Adds `/apds` GET request; updates relationship between APDs and states\r\n\r\n### This pull request is ready to merge when...\r\n- [ ] Tests have been updated (and all tests are passing)\r\n- [ ] This code has been reviewed by someone other than the original author\r\n- ~The experience passes a basic manual accessibility audit (keyboard nav, screenreader, text scaling) OR an exemption is documented~\r\n- [x] The change has been documented\r\n  - [x] Associated OpenAPI documentation has been updated\r\n\r\n### This feature is done when...\r\n- ~Design has approved the experience~\r\n- ~Product has approved the experience~\r\n","created_at":"2018-03-09T15:38:08Z","updated_at":"2018-03-09T22:01:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e47981c0dd3ff6879796e7a57df0c49e282f12d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/293/commits","review_comments_url":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/293/comments","review_comment_url":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/293/comments","statuses_url":"https://api.github.com/repos/18F/cms-hitech-apd/statuses/945899b77655d0e95dad3086316d1502670fea92","head":{"label":"18F:bjs-start-apd-endpoints","ref":"bjs-start-apd-endpoints","sha":"945899b77655d0e95dad3086316d1502670fea92","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars0.githubusercontent.com/u/6233994?v=4","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":113234315,"name":"cms-hitech-apd","full_name":"18F/cms-hitech-apd","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars0.githubusercontent.com/u/6233994?v=4","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/cms-hitech-apd","description":"Centers for Medicare and Medicaid Services (CMS) HITECH funding request app","fork":false,"url":"https://api.github.com/repos/18F/cms-hitech-apd","forks_url":"https://api.github.com/repos/18F/cms-hitech-apd/forks","keys_url":"https://api.github.com/repos/18F/cms-hitech-apd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/cms-hitech-apd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/cms-hitech-apd/teams","hooks_url":"https://api.github.com/repos/18F/cms-hitech-apd/hooks","issue_events_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/events{/number}","events_url":"https://api.github.com/repos/18F/cms-hitech-apd/events","assignees_url":"https://api.github.com/repos/18F/cms-hitech-apd/assignees{/user}","branches_url":"https://api.github.com/repos/18F/cms-hitech-apd/branches{/branch}","tags_url":"https://api.github.com/repos/18F/cms-hitech-apd/tags","blobs_url":"https://api.github.com/repos/18F/cms-hitech-apd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/cms-hitech-apd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/cms-hitech-apd/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/cms-hitech-apd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/cms-hitech-apd/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/cms-hitech-apd/languages","stargazers_url":"https://api.github.com/repos/18F/cms-hitech-apd/stargazers","contributors_url":"https://api.github.com/repos/18F/cms-hitech-apd/contributors","subscribers_url":"https://api.github.com/repos/18F/cms-hitech-apd/subscribers","subscription_url":"https://api.github.com/repos/18F/cms-hitech-apd/subscription","commits_url":"https://api.github.com/repos/18F/cms-hitech-apd/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/cms-hitech-apd/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/cms-hitech-apd/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/cms-hitech-apd/contents/{+path}","compare_url":"https://api.github.com/repos/18F/cms-hitech-apd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/cms-hitech-apd/merges","archive_url":"https://api.github.com/repos/18F/cms-hitech-apd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/cms-hitech-apd/downloads","issues_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues{/number}","pulls_url":"https://api.github.com/repos/18F/cms-hitech-apd/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/cms-hitech-apd/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/cms-hitech-apd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/cms-hitech-apd/labels{/name}","releases_url":"https://api.github.com/repos/18F/cms-hitech-apd/releases{/id}","deployments_url":"https://api.github.com/repos/18F/cms-hitech-apd/deployments","created_at":"2017-12-05T21:20:35Z","updated_at":"2018-03-02T19:23:34Z","pushed_at":"2018-03-09T19:55:35Z","git_url":"git://github.com/18F/cms-hitech-apd.git","ssh_url":"git@github.com:18F/cms-hitech-apd.git","clone_url":"https://github.com/18F/cms-hitech-apd.git","svn_url":"https://github.com/18F/cms-hitech-apd","homepage":"","size":1448,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":43,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":43,"watchers":6,"default_branch":"master"}},"base":{"label":"18F:master","ref":"master","sha":"ba8a6447f19d59e79be3e507e29d964672781070","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars0.githubusercontent.com/u/6233994?v=4","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":113234315,"name":"cms-hitech-apd","full_name":"18F/cms-hitech-apd","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars0.githubusercontent.com/u/6233994?v=4","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/cms-hitech-apd","description":"Centers for Medicare and Medicaid Services (CMS) HITECH funding request app","fork":false,"url":"https://api.github.com/repos/18F/cms-hitech-apd","forks_url":"https://api.github.com/repos/18F/cms-hitech-apd/forks","keys_url":"https://api.github.com/repos/18F/cms-hitech-apd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/cms-hitech-apd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/cms-hitech-apd/teams","hooks_url":"https://api.github.com/repos/18F/cms-hitech-apd/hooks","issue_events_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/events{/number}","events_url":"https://api.github.com/repos/18F/cms-hitech-apd/events","assignees_url":"https://api.github.com/repos/18F/cms-hitech-apd/assignees{/user}","branches_url":"https://api.github.com/repos/18F/cms-hitech-apd/branches{/branch}","tags_url":"https://api.github.com/repos/18F/cms-hitech-apd/tags","blobs_url":"https://api.github.com/repos/18F/cms-hitech-apd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/cms-hitech-apd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/cms-hitech-apd/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/cms-hitech-apd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/cms-hitech-apd/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/cms-hitech-apd/languages","stargazers_url":"https://api.github.com/repos/18F/cms-hitech-apd/stargazers","contributors_url":"https://api.github.com/repos/18F/cms-hitech-apd/contributors","subscribers_url":"https://api.github.com/repos/18F/cms-hitech-apd/subscribers","subscription_url":"https://api.github.com/repos/18F/cms-hitech-apd/subscription","commits_url":"https://api.github.com/repos/18F/cms-hitech-apd/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/cms-hitech-apd/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/cms-hitech-apd/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/cms-hitech-apd/contents/{+path}","compare_url":"https://api.github.com/repos/18F/cms-hitech-apd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/cms-hitech-apd/merges","archive_url":"https://api.github.com/repos/18F/cms-hitech-apd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/cms-hitech-apd/downloads","issues_url":"https://api.github.com/repos/18F/cms-hitech-apd/issues{/number}","pulls_url":"https://api.github.com/repos/18F/cms-hitech-apd/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/cms-hitech-apd/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/cms-hitech-apd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/cms-hitech-apd/labels{/name}","releases_url":"https://api.github.com/repos/18F/cms-hitech-apd/releases{/id}","deployments_url":"https://api.github.com/repos/18F/cms-hitech-apd/deployments","created_at":"2017-12-05T21:20:35Z","updated_at":"2018-03-02T19:23:34Z","pushed_at":"2018-03-09T19:55:35Z","git_url":"git://github.com/18F/cms-hitech-apd.git","ssh_url":"git@github.com:18F/cms-hitech-apd.git","clone_url":"https://github.com/18F/cms-hitech-apd.git","svn_url":"https://github.com/18F/cms-hitech-apd","homepage":"","size":1448,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":43,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":43,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/293"},"html":{"href":"https://github.com/18F/cms-hitech-apd/pull/293"},"issue":{"href":"https://api.github.com/repos/18F/cms-hitech-apd/issues/293"},"comments":{"href":"https://api.github.com/repos/18F/cms-hitech-apd/issues/293/comments"},"review_comments":{"href":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/293/comments"},"review_comment":{"href":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/18F/cms-hitech-apd/pulls/293/commits"},"statuses":{"href":"https://api.github.com/repos/18F/cms-hitech-apd/statuses/945899b77655d0e95dad3086316d1502670fea92"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"brendansudol"}}