{"action":"created","comment":{"url":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/comments/59320419","id":59320419,"diff_hunk":"@@ -0,0 +1,305 @@\n+var config = require('../config'),\n+  osdi = require('../lib/osdi'),\n+  _ = require('lodash'),\n+  bridge = require('../lib/bridge'),\n+  selectn = require('selectn');\n+\n+var Promise = require('bluebird');\n+\n+// Events\n+function getAll(req, res) {\n+  var vanClient = bridge.createClient(req);\n+  var vanPaginationParams = bridge.getVANPaginationParams(req);\n+  var expand = ['locations', 'codes', 'shifts', 'roles', 'notes'];\n+\n+  var resourcePromise = vanClient.events.getMany(expand, vanPaginationParams.top, vanPaginationParams.skip);\n+\n+  bridge.sendMultiResourceResponse(resourcePromise, vanPaginationParams,\n+    oneResourceTranslator, 'events', res);\n+}\n+\n+// Events\n+function getOne(req, res) {\n+  var vanClient = bridge.createClient(req);\n+  var originalVanEvent = null;\n+  var id = 0;\n+  if (req && req.params && req.params.id) {\n+    id = req.params.id;\n+  }\n+  var expand = ['locations', 'codes', 'shifts', 'roles', 'notes'];\n+  var resourcePromise = vanClient.events.getOne(id, expand).then(function (vanEvent) {\n+    originalVanEvent = vanEvent;\n+    var eventTypeId=vanEvent.eventType.eventTypeId;\n+    return vanClient.events.getEventType(eventTypeId);\n+  }).then(function(vanEventType){\n+    originalVanEvent.vanEventTypeBlock=vanEventType;\n+    return originalVanEvent;\n+  });\n+\n+  bridge.sendSingleResourceResponse(resourcePromise, oneResourceTranslator,\n+    'events', res);\n+}\n+\n+\n+function oneResourceTranslator(vanitem) {\n+  var answer = osdi.response.createCommonItem(\n+    vanitem.shortName,\n+    vanitem.description);\n+  answer.title = vanitem.name;\n+  answer.summary = answer.description;\n+\n+  answer['van:statuses'] = _.map(selectn('vanEventTypeBlock.statuses',vanitem),function(status){\n+    return {\n+      status_id: status.statusId,\n+      name: status.name,\n+      is_event_lead: status.isEventLead\n+    }","path":"routes/events.js","position":92,"original_position":56,"commit_id":"1aafa80451dca6dfa9378bbfb09f0202773a197c","original_commit_id":"0dd9254dc57a5f12cc5a060d4c8e4ce7f78b4e17","user":{"login":"joshco","id":290314,"avatar_url":"https://avatars.githubusercontent.com/u/290314?v=3","gravatar_id":"","url":"https://api.github.com/users/joshco","html_url":"https://github.com/joshco","followers_url":"https://api.github.com/users/joshco/followers","following_url":"https://api.github.com/users/joshco/following{/other_user}","gists_url":"https://api.github.com/users/joshco/gists{/gist_id}","starred_url":"https://api.github.com/users/joshco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshco/subscriptions","organizations_url":"https://api.github.com/users/joshco/orgs","repos_url":"https://api.github.com/users/joshco/repos","events_url":"https://api.github.com/users/joshco/events{/privacy}","received_events_url":"https://api.github.com/users/joshco/received_events","type":"User","site_admin":false},"body":"Is the set of 25 fixed or can a tenant create their own status? (eg can I create a status called \"Flaked\"?)\r\nWill they always have the same numeric ID? (will Scheduled always == 1)","created_at":"2016-04-12T04:49:12Z","updated_at":"2016-04-12T04:49:12Z","html_url":"https://github.com/NGPVAN/osdi-service/pull/7#discussion_r59320419","pull_request_url":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/comments/59320419"},"html":{"href":"https://github.com/NGPVAN/osdi-service/pull/7#discussion_r59320419"},"pull_request":{"href":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/7","id":63481362,"html_url":"https://github.com/NGPVAN/osdi-service/pull/7","diff_url":"https://github.com/NGPVAN/osdi-service/pull/7.diff","patch_url":"https://github.com/NGPVAN/osdi-service/pull/7.patch","issue_url":"https://api.github.com/repos/NGPVAN/osdi-service/issues/7","number":7,"state":"open","locked":false,"title":"Events and Scripts","user":{"login":"joshco","id":290314,"avatar_url":"https://avatars.githubusercontent.com/u/290314?v=3","gravatar_id":"","url":"https://api.github.com/users/joshco","html_url":"https://github.com/joshco","followers_url":"https://api.github.com/users/joshco/followers","following_url":"https://api.github.com/users/joshco/following{/other_user}","gists_url":"https://api.github.com/users/joshco/gists{/gist_id}","starred_url":"https://api.github.com/users/joshco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshco/subscriptions","organizations_url":"https://api.github.com/users/joshco/orgs","repos_url":"https://api.github.com/users/joshco/repos","events_url":"https://api.github.com/users/joshco/events{/privacy}","received_events_url":"https://api.github.com/users/joshco/received_events","type":"User","site_admin":false},"body":"I've removed WIP from this PR because I think it's ready for an approval discussion\r\n## Events\r\nEvents are now supported:\r\n* GET events/ (collection)\r\n* GET events/:id (individual)\r\n* GET events/:id/attendances (collection of attendances/signups)\r\n* GET attendances/:id (individual GET on an attendance/signup)\r\n* POST events/:id/record_attendance_helper (signup for an event)\r\n\r\nEvent representations include the relevant roles, shifts, statuses, etc\r\n\r\n## Scripts\r\nScripts are supported along with script_question which is the association between a question and a script and where sequence is defined\r\n\r\n* GET scripts/ (collection)\r\n* GET scripts/:id (individual, which contains embedded script_questions and questions)\r\n\r\nTODO synthetic links for script_questions\r\nsynthetic script_questions added","created_at":"2016-03-19T22:58:53Z","updated_at":"2016-04-12T04:49:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5e5ed14b633d0d09f6fcbb32f9388c062a8d4b98","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/7/commits","review_comments_url":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/7/comments","review_comment_url":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NGPVAN/osdi-service/issues/7/comments","statuses_url":"https://api.github.com/repos/NGPVAN/osdi-service/statuses/1aafa80451dca6dfa9378bbfb09f0202773a197c","head":{"label":"joshco:events","ref":"events","sha":"1aafa80451dca6dfa9378bbfb09f0202773a197c","user":{"login":"joshco","id":290314,"avatar_url":"https://avatars.githubusercontent.com/u/290314?v=3","gravatar_id":"","url":"https://api.github.com/users/joshco","html_url":"https://github.com/joshco","followers_url":"https://api.github.com/users/joshco/followers","following_url":"https://api.github.com/users/joshco/following{/other_user}","gists_url":"https://api.github.com/users/joshco/gists{/gist_id}","starred_url":"https://api.github.com/users/joshco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshco/subscriptions","organizations_url":"https://api.github.com/users/joshco/orgs","repos_url":"https://api.github.com/users/joshco/repos","events_url":"https://api.github.com/users/joshco/events{/privacy}","received_events_url":"https://api.github.com/users/joshco/received_events","type":"User","site_admin":false},"repo":{"id":39165230,"name":"osdi-service","full_name":"joshco/osdi-service","owner":{"login":"joshco","id":290314,"avatar_url":"https://avatars.githubusercontent.com/u/290314?v=3","gravatar_id":"","url":"https://api.github.com/users/joshco","html_url":"https://github.com/joshco","followers_url":"https://api.github.com/users/joshco/followers","following_url":"https://api.github.com/users/joshco/following{/other_user}","gists_url":"https://api.github.com/users/joshco/gists{/gist_id}","starred_url":"https://api.github.com/users/joshco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshco/subscriptions","organizations_url":"https://api.github.com/users/joshco/orgs","repos_url":"https://api.github.com/users/joshco/repos","events_url":"https://api.github.com/users/joshco/events{/privacy}","received_events_url":"https://api.github.com/users/joshco/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joshco/osdi-service","description":"Access to VAN resources that complies with the OSDI specification. See http://opensupporter.org/","fork":true,"url":"https://api.github.com/repos/joshco/osdi-service","forks_url":"https://api.github.com/repos/joshco/osdi-service/forks","keys_url":"https://api.github.com/repos/joshco/osdi-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joshco/osdi-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joshco/osdi-service/teams","hooks_url":"https://api.github.com/repos/joshco/osdi-service/hooks","issue_events_url":"https://api.github.com/repos/joshco/osdi-service/issues/events{/number}","events_url":"https://api.github.com/repos/joshco/osdi-service/events","assignees_url":"https://api.github.com/repos/joshco/osdi-service/assignees{/user}","branches_url":"https://api.github.com/repos/joshco/osdi-service/branches{/branch}","tags_url":"https://api.github.com/repos/joshco/osdi-service/tags","blobs_url":"https://api.github.com/repos/joshco/osdi-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joshco/osdi-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joshco/osdi-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/joshco/osdi-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joshco/osdi-service/statuses/{sha}","languages_url":"https://api.github.com/repos/joshco/osdi-service/languages","stargazers_url":"https://api.github.com/repos/joshco/osdi-service/stargazers","contributors_url":"https://api.github.com/repos/joshco/osdi-service/contributors","subscribers_url":"https://api.github.com/repos/joshco/osdi-service/subscribers","subscription_url":"https://api.github.com/repos/joshco/osdi-service/subscription","commits_url":"https://api.github.com/repos/joshco/osdi-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/joshco/osdi-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/joshco/osdi-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/joshco/osdi-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/joshco/osdi-service/contents/{+path}","compare_url":"https://api.github.com/repos/joshco/osdi-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joshco/osdi-service/merges","archive_url":"https://api.github.com/repos/joshco/osdi-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joshco/osdi-service/downloads","issues_url":"https://api.github.com/repos/joshco/osdi-service/issues{/number}","pulls_url":"https://api.github.com/repos/joshco/osdi-service/pulls{/number}","milestones_url":"https://api.github.com/repos/joshco/osdi-service/milestones{/number}","notifications_url":"https://api.github.com/repos/joshco/osdi-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joshco/osdi-service/labels{/name}","releases_url":"https://api.github.com/repos/joshco/osdi-service/releases{/id}","deployments_url":"https://api.github.com/repos/joshco/osdi-service/deployments","created_at":"2015-07-15T23:00:03Z","updated_at":"2015-07-15T23:00:04Z","pushed_at":"2016-04-12T04:46:04Z","git_url":"git://github.com/joshco/osdi-service.git","ssh_url":"git@github.com:joshco/osdi-service.git","clone_url":"https://github.com/joshco/osdi-service.git","svn_url":"https://github.com/joshco/osdi-service","homepage":null,"size":141,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"NGPVAN:master","ref":"master","sha":"6646de43cd1c400af51023a7feb9b1948c29a997","user":{"login":"NGPVAN","id":729820,"avatar_url":"https://avatars.githubusercontent.com/u/729820?v=3","gravatar_id":"","url":"https://api.github.com/users/NGPVAN","html_url":"https://github.com/NGPVAN","followers_url":"https://api.github.com/users/NGPVAN/followers","following_url":"https://api.github.com/users/NGPVAN/following{/other_user}","gists_url":"https://api.github.com/users/NGPVAN/gists{/gist_id}","starred_url":"https://api.github.com/users/NGPVAN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NGPVAN/subscriptions","organizations_url":"https://api.github.com/users/NGPVAN/orgs","repos_url":"https://api.github.com/users/NGPVAN/repos","events_url":"https://api.github.com/users/NGPVAN/events{/privacy}","received_events_url":"https://api.github.com/users/NGPVAN/received_events","type":"Organization","site_admin":false},"repo":{"id":32401551,"name":"osdi-service","full_name":"NGPVAN/osdi-service","owner":{"login":"NGPVAN","id":729820,"avatar_url":"https://avatars.githubusercontent.com/u/729820?v=3","gravatar_id":"","url":"https://api.github.com/users/NGPVAN","html_url":"https://github.com/NGPVAN","followers_url":"https://api.github.com/users/NGPVAN/followers","following_url":"https://api.github.com/users/NGPVAN/following{/other_user}","gists_url":"https://api.github.com/users/NGPVAN/gists{/gist_id}","starred_url":"https://api.github.com/users/NGPVAN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NGPVAN/subscriptions","organizations_url":"https://api.github.com/users/NGPVAN/orgs","repos_url":"https://api.github.com/users/NGPVAN/repos","events_url":"https://api.github.com/users/NGPVAN/events{/privacy}","received_events_url":"https://api.github.com/users/NGPVAN/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NGPVAN/osdi-service","description":"Access to VAN resources that complies with the OSDI specification. See http://opensupporter.org/","fork":false,"url":"https://api.github.com/repos/NGPVAN/osdi-service","forks_url":"https://api.github.com/repos/NGPVAN/osdi-service/forks","keys_url":"https://api.github.com/repos/NGPVAN/osdi-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NGPVAN/osdi-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NGPVAN/osdi-service/teams","hooks_url":"https://api.github.com/repos/NGPVAN/osdi-service/hooks","issue_events_url":"https://api.github.com/repos/NGPVAN/osdi-service/issues/events{/number}","events_url":"https://api.github.com/repos/NGPVAN/osdi-service/events","assignees_url":"https://api.github.com/repos/NGPVAN/osdi-service/assignees{/user}","branches_url":"https://api.github.com/repos/NGPVAN/osdi-service/branches{/branch}","tags_url":"https://api.github.com/repos/NGPVAN/osdi-service/tags","blobs_url":"https://api.github.com/repos/NGPVAN/osdi-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NGPVAN/osdi-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NGPVAN/osdi-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/NGPVAN/osdi-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NGPVAN/osdi-service/statuses/{sha}","languages_url":"https://api.github.com/repos/NGPVAN/osdi-service/languages","stargazers_url":"https://api.github.com/repos/NGPVAN/osdi-service/stargazers","contributors_url":"https://api.github.com/repos/NGPVAN/osdi-service/contributors","subscribers_url":"https://api.github.com/repos/NGPVAN/osdi-service/subscribers","subscription_url":"https://api.github.com/repos/NGPVAN/osdi-service/subscription","commits_url":"https://api.github.com/repos/NGPVAN/osdi-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/NGPVAN/osdi-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/NGPVAN/osdi-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/NGPVAN/osdi-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/NGPVAN/osdi-service/contents/{+path}","compare_url":"https://api.github.com/repos/NGPVAN/osdi-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NGPVAN/osdi-service/merges","archive_url":"https://api.github.com/repos/NGPVAN/osdi-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NGPVAN/osdi-service/downloads","issues_url":"https://api.github.com/repos/NGPVAN/osdi-service/issues{/number}","pulls_url":"https://api.github.com/repos/NGPVAN/osdi-service/pulls{/number}","milestones_url":"https://api.github.com/repos/NGPVAN/osdi-service/milestones{/number}","notifications_url":"https://api.github.com/repos/NGPVAN/osdi-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NGPVAN/osdi-service/labels{/name}","releases_url":"https://api.github.com/repos/NGPVAN/osdi-service/releases{/id}","deployments_url":"https://api.github.com/repos/NGPVAN/osdi-service/deployments","created_at":"2015-03-17T15:20:53Z","updated_at":"2016-02-25T18:41:07Z","pushed_at":"2016-04-12T04:46:04Z","git_url":"git://github.com/NGPVAN/osdi-service.git","ssh_url":"git@github.com:NGPVAN/osdi-service.git","clone_url":"https://github.com/NGPVAN/osdi-service.git","svn_url":"https://github.com/NGPVAN/osdi-service","homepage":null,"size":139,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/7"},"html":{"href":"https://github.com/NGPVAN/osdi-service/pull/7"},"issue":{"href":"https://api.github.com/repos/NGPVAN/osdi-service/issues/7"},"comments":{"href":"https://api.github.com/repos/NGPVAN/osdi-service/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NGPVAN/osdi-service/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/NGPVAN/osdi-service/statuses/1aafa80451dca6dfa9378bbfb09f0202773a197c"}}}}