{"action":"created","comment":{"url":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/comments/84606423","pull_request_review_id":5371914,"id":84606423,"diff_hunk":"@@ -0,0 +1,166 @@\n+var db = require('./db')\n+\n+module.exports = {\n+  getDonors: getDonors,\n+  getRecipients: getRecipients,\n+  getDonor: getDonor,\n+  getRecipient: getRecipient,\n+  updateTicket: updateTicket,\n+  updateComment: updateComment,\n+  getTickets: getTickets,\n+  addTicket: addTicket,\n+  getDonorTicket: getDonorTicket,\n+  getRecipientTicket: getRecipientTicket,\n+  getTicketComments: getTicketComments\n+}\n+\n+function getDonors(req, res) {\n+  db.getDonors()\n+    .then(function (donors) {\n+      res.json(donors)\n+    })\n+    .catch(function (err) {\n+      res.send(err.message).status(500)\n+    })\n+}\n+\n+function getRecipients(req, res) {\n+  db.getRecipients()\n+    .then(function (recipients) {\n+      res.json(recipients)\n+    })\n+    .catch(function (err) {\n+      res.send(err.message).status(500)\n+    })\n+}\n+\n+function getDonor(req, res) {\n+  var donorId = req.params.id\n+  db.getDonor(donorId)\n+    .then(function (donor) {\n+      res.json(donor)\n+    })\n+    .catch(function (err) {\n+      res.send(err.message).status(500)\n+    })\n+}\n+\n+function getRecipient(req, res) {\n+  var recipientId = req.params.id\n+  db.getRecipient(recipientId)\n+    .then(function (recipient) {\n+      res.json(recipient)\n+    })\n+    .catch(function (err) {\n+      res.send(err.message).status(500)\n+    })\n+}\n+\n+function updateTicket(req, res) {\n+  var ticket = {\n+    id: req.body.ticketId,\n+    actualKg: req.body.actualKg,\n+  }\n+  db.updateTicket(ticket)\n+    .then(function () {\n+      res.json(ticket)\n+    })\n+    .catch(function (err) {\n+      res.send(err.message).status(500)\n+    })\n+}\n+\n+function updateComment(req, res) {\n+  var comment = {\n+    ticketId: req.body.ticketId,\n+    comment: req.body.comment\n+  }\n+  db.updateComment(comment)\n+    .then(function () {\n+      res.json(comment)\n+    })\n+    .catch(function (err) {\n+      res.send(err.message).status(500)\n+    })\n+}\n+\n+// \"has to match table column name, use _\": req.body.useCamelCase\n+  function addTicket(req, res) {\n+    console.log(req.body.recipientId)\n+    if (!req.body.recipientId) {\n+      var ticket = {\n+        expected_kg: req.body.expectedKg,\n+        donor_id: req.body.donorId.split('|')[0],\n+        details_id: req.body.donorId.split('|')[1],\n+        is_complete: 0\n+      }\n+    } else {\n+      var ticket = {\n+        expected_kg: req.body.expectedKg,\n+        recipient_id: req.body.recipientId.split('|')[0],\n+        details_id: req.body.recipientId.split('|')[1],\n+        is_complete: 0\n+      }\n+    }\n+    console.log(ticket)\n+    db.addTicket(ticket)\n+      .then(function () {\n+        res.json(ticket)\n+      })\n+      .catch(function (err) {\n+        res.send(err.message).status(500)\n+      })\n+  }\n+\n+function getTickets(req, res) {\n+  db.getTickets()\n+    .then(function (tickets) {\n+      res.json(tickets)\n+    })\n+    .catch(function (err) {\n+      res.send(err.message).status(500)\n+    })\n+}\n+\n+function getDonorTicket(req, res) {\n+  var ticketId = req.params.id\n+  db.getDonorTicket(ticketId)\n+    .then(function (donorTicket) {\n+      res.json(donorTicket)\n+    })\n+    .catch(function (err) {\n+      res.send(err.message).status(500)\n+    })\n+}\n+\n+function getRecipientTicket(req, res) {\n+  var ticketId = req.params.id\n+  db.getRecipientTicket(ticketId)\n+    .then(function (recipientTicket) {\n+      res.json(recipientTicket)\n+    })\n+    .catch(function (err) {\n+      res.send(err.message).status(500)\n+    })\n+}\n+\n+function getTicketComments(req, res) {\n+  var ticketId = req.params.id\n+  db.getTicketComments(ticketId)\n+    .then(function (ticketComments) {\n+      var singleTicketComments = []\n+      var foundComments = []\n+      for (var i = 0; i < ticketComments.length; i++) {\n+        if (!foundComments.includes(ticketComments[i].comments)) {\n+          singleTicketComments.push({\n+            comments: ticketComments[i].comments\n+          })\n+          foundComments.push(ticketComments[i].comments)\n+        }\n+      }\n+      res.json(singleTicketComments)","path":"server/routes.js","position":161,"original_position":161,"commit_id":"e1e1a938f7f33063b4d15392121fb74e96bcfada","original_commit_id":"e1e1a938f7f33063b4d15392121fb74e96bcfada","user":{"login":"richchurcher","id":171905,"avatar_url":"https://avatars.githubusercontent.com/u/171905?v=3","gravatar_id":"","url":"https://api.github.com/users/richchurcher","html_url":"https://github.com/richchurcher","followers_url":"https://api.github.com/users/richchurcher/followers","following_url":"https://api.github.com/users/richchurcher/following{/other_user}","gists_url":"https://api.github.com/users/richchurcher/gists{/gist_id}","starred_url":"https://api.github.com/users/richchurcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richchurcher/subscriptions","organizations_url":"https://api.github.com/users/richchurcher/orgs","repos_url":"https://api.github.com/users/richchurcher/repos","events_url":"https://api.github.com/users/richchurcher/events{/privacy}","received_events_url":"https://api.github.com/users/richchurcher/received_events","type":"User","site_admin":false},"body":"This route was a bit of a WTF moment for me :) I actually have no idea what it's doing. `db.getTicketComments` already retrieves the comments for a single ticket, so I'm not sure why all the additional processing?","created_at":"2016-10-23T22:09:54Z","updated_at":"2016-10-23T22:21:45Z","html_url":"https://github.com/kahikatea-2016/harvestr/pull/81#discussion_r84606423","pull_request_url":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/81","_links":{"self":{"href":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/comments/84606423"},"html":{"href":"https://github.com/kahikatea-2016/harvestr/pull/81#discussion_r84606423"},"pull_request":{"href":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/81"}}},"pull_request":{"url":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/81","id":90529257,"html_url":"https://github.com/kahikatea-2016/harvestr/pull/81","diff_url":"https://github.com/kahikatea-2016/harvestr/pull/81.diff","patch_url":"https://github.com/kahikatea-2016/harvestr/pull/81.patch","issue_url":"https://api.github.com/repos/kahikatea-2016/harvestr/issues/81","number":81,"state":"open","locked":false,"title":"Code Review","user":{"login":"richchurcher","id":171905,"avatar_url":"https://avatars.githubusercontent.com/u/171905?v=3","gravatar_id":"","url":"https://api.github.com/users/richchurcher","html_url":"https://github.com/richchurcher","followers_url":"https://api.github.com/users/richchurcher/followers","following_url":"https://api.github.com/users/richchurcher/following{/other_user}","gists_url":"https://api.github.com/users/richchurcher/gists{/gist_id}","starred_url":"https://api.github.com/users/richchurcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richchurcher/subscriptions","organizations_url":"https://api.github.com/users/richchurcher/orgs","repos_url":"https://api.github.com/users/richchurcher/repos","events_url":"https://api.github.com/users/richchurcher/events{/privacy}","received_events_url":"https://api.github.com/users/richchurcher/received_events","type":"User","site_admin":false},"body":"Don't merge this PR! It's just for you to read the review comments/suggestions.","created_at":"2016-10-23T20:49:40Z","updated_at":"2016-10-23T22:21:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c65837207c6fa42503815a4f3ed9163f06f3547e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/81/commits","review_comments_url":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/81/comments","review_comment_url":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kahikatea-2016/harvestr/issues/81/comments","statuses_url":"https://api.github.com/repos/kahikatea-2016/harvestr/statuses/e1e1a938f7f33063b4d15392121fb74e96bcfada","head":{"label":"kahikatea-2016:dev","ref":"dev","sha":"e1e1a938f7f33063b4d15392121fb74e96bcfada","user":{"login":"kahikatea-2016","id":20103763,"avatar_url":"https://avatars.githubusercontent.com/u/20103763?v=3","gravatar_id":"","url":"https://api.github.com/users/kahikatea-2016","html_url":"https://github.com/kahikatea-2016","followers_url":"https://api.github.com/users/kahikatea-2016/followers","following_url":"https://api.github.com/users/kahikatea-2016/following{/other_user}","gists_url":"https://api.github.com/users/kahikatea-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/kahikatea-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kahikatea-2016/subscriptions","organizations_url":"https://api.github.com/users/kahikatea-2016/orgs","repos_url":"https://api.github.com/users/kahikatea-2016/repos","events_url":"https://api.github.com/users/kahikatea-2016/events{/privacy}","received_events_url":"https://api.github.com/users/kahikatea-2016/received_events","type":"Organization","site_admin":false},"repo":{"id":71320603,"name":"harvestr","full_name":"kahikatea-2016/harvestr","owner":{"login":"kahikatea-2016","id":20103763,"avatar_url":"https://avatars.githubusercontent.com/u/20103763?v=3","gravatar_id":"","url":"https://api.github.com/users/kahikatea-2016","html_url":"https://github.com/kahikatea-2016","followers_url":"https://api.github.com/users/kahikatea-2016/followers","following_url":"https://api.github.com/users/kahikatea-2016/following{/other_user}","gists_url":"https://api.github.com/users/kahikatea-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/kahikatea-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kahikatea-2016/subscriptions","organizations_url":"https://api.github.com/users/kahikatea-2016/orgs","repos_url":"https://api.github.com/users/kahikatea-2016/repos","events_url":"https://api.github.com/users/kahikatea-2016/events{/privacy}","received_events_url":"https://api.github.com/users/kahikatea-2016/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kahikatea-2016/harvestr","description":null,"fork":false,"url":"https://api.github.com/repos/kahikatea-2016/harvestr","forks_url":"https://api.github.com/repos/kahikatea-2016/harvestr/forks","keys_url":"https://api.github.com/repos/kahikatea-2016/harvestr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kahikatea-2016/harvestr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kahikatea-2016/harvestr/teams","hooks_url":"https://api.github.com/repos/kahikatea-2016/harvestr/hooks","issue_events_url":"https://api.github.com/repos/kahikatea-2016/harvestr/issues/events{/number}","events_url":"https://api.github.com/repos/kahikatea-2016/harvestr/events","assignees_url":"https://api.github.com/repos/kahikatea-2016/harvestr/assignees{/user}","branches_url":"https://api.github.com/repos/kahikatea-2016/harvestr/branches{/branch}","tags_url":"https://api.github.com/repos/kahikatea-2016/harvestr/tags","blobs_url":"https://api.github.com/repos/kahikatea-2016/harvestr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kahikatea-2016/harvestr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kahikatea-2016/harvestr/git/refs{/sha}","trees_url":"https://api.github.com/repos/kahikatea-2016/harvestr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kahikatea-2016/harvestr/statuses/{sha}","languages_url":"https://api.github.com/repos/kahikatea-2016/harvestr/languages","stargazers_url":"https://api.github.com/repos/kahikatea-2016/harvestr/stargazers","contributors_url":"https://api.github.com/repos/kahikatea-2016/harvestr/contributors","subscribers_url":"https://api.github.com/repos/kahikatea-2016/harvestr/subscribers","subscription_url":"https://api.github.com/repos/kahikatea-2016/harvestr/subscription","commits_url":"https://api.github.com/repos/kahikatea-2016/harvestr/commits{/sha}","git_commits_url":"https://api.github.com/repos/kahikatea-2016/harvestr/git/commits{/sha}","comments_url":"https://api.github.com/repos/kahikatea-2016/harvestr/comments{/number}","issue_comment_url":"https://api.github.com/repos/kahikatea-2016/harvestr/issues/comments{/number}","contents_url":"https://api.github.com/repos/kahikatea-2016/harvestr/contents/{+path}","compare_url":"https://api.github.com/repos/kahikatea-2016/harvestr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kahikatea-2016/harvestr/merges","archive_url":"https://api.github.com/repos/kahikatea-2016/harvestr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kahikatea-2016/harvestr/downloads","issues_url":"https://api.github.com/repos/kahikatea-2016/harvestr/issues{/number}","pulls_url":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls{/number}","milestones_url":"https://api.github.com/repos/kahikatea-2016/harvestr/milestones{/number}","notifications_url":"https://api.github.com/repos/kahikatea-2016/harvestr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kahikatea-2016/harvestr/labels{/name}","releases_url":"https://api.github.com/repos/kahikatea-2016/harvestr/releases{/id}","deployments_url":"https://api.github.com/repos/kahikatea-2016/harvestr/deployments","created_at":"2016-10-19T05:01:53Z","updated_at":"2016-10-22T02:39:18Z","pushed_at":"2016-10-23T22:05:03Z","git_url":"git://github.com/kahikatea-2016/harvestr.git","ssh_url":"git@github.com:kahikatea-2016/harvestr.git","clone_url":"https://github.com/kahikatea-2016/harvestr.git","svn_url":"https://github.com/kahikatea-2016/harvestr","homepage":null,"size":10428,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":0,"default_branch":"dev"}},"base":{"label":"kahikatea-2016:code-review","ref":"code-review","sha":"4a8caa59d93516e069b90c7f2578754acc845a10","user":{"login":"kahikatea-2016","id":20103763,"avatar_url":"https://avatars.githubusercontent.com/u/20103763?v=3","gravatar_id":"","url":"https://api.github.com/users/kahikatea-2016","html_url":"https://github.com/kahikatea-2016","followers_url":"https://api.github.com/users/kahikatea-2016/followers","following_url":"https://api.github.com/users/kahikatea-2016/following{/other_user}","gists_url":"https://api.github.com/users/kahikatea-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/kahikatea-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kahikatea-2016/subscriptions","organizations_url":"https://api.github.com/users/kahikatea-2016/orgs","repos_url":"https://api.github.com/users/kahikatea-2016/repos","events_url":"https://api.github.com/users/kahikatea-2016/events{/privacy}","received_events_url":"https://api.github.com/users/kahikatea-2016/received_events","type":"Organization","site_admin":false},"repo":{"id":71320603,"name":"harvestr","full_name":"kahikatea-2016/harvestr","owner":{"login":"kahikatea-2016","id":20103763,"avatar_url":"https://avatars.githubusercontent.com/u/20103763?v=3","gravatar_id":"","url":"https://api.github.com/users/kahikatea-2016","html_url":"https://github.com/kahikatea-2016","followers_url":"https://api.github.com/users/kahikatea-2016/followers","following_url":"https://api.github.com/users/kahikatea-2016/following{/other_user}","gists_url":"https://api.github.com/users/kahikatea-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/kahikatea-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kahikatea-2016/subscriptions","organizations_url":"https://api.github.com/users/kahikatea-2016/orgs","repos_url":"https://api.github.com/users/kahikatea-2016/repos","events_url":"https://api.github.com/users/kahikatea-2016/events{/privacy}","received_events_url":"https://api.github.com/users/kahikatea-2016/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kahikatea-2016/harvestr","description":null,"fork":false,"url":"https://api.github.com/repos/kahikatea-2016/harvestr","forks_url":"https://api.github.com/repos/kahikatea-2016/harvestr/forks","keys_url":"https://api.github.com/repos/kahikatea-2016/harvestr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kahikatea-2016/harvestr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kahikatea-2016/harvestr/teams","hooks_url":"https://api.github.com/repos/kahikatea-2016/harvestr/hooks","issue_events_url":"https://api.github.com/repos/kahikatea-2016/harvestr/issues/events{/number}","events_url":"https://api.github.com/repos/kahikatea-2016/harvestr/events","assignees_url":"https://api.github.com/repos/kahikatea-2016/harvestr/assignees{/user}","branches_url":"https://api.github.com/repos/kahikatea-2016/harvestr/branches{/branch}","tags_url":"https://api.github.com/repos/kahikatea-2016/harvestr/tags","blobs_url":"https://api.github.com/repos/kahikatea-2016/harvestr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kahikatea-2016/harvestr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kahikatea-2016/harvestr/git/refs{/sha}","trees_url":"https://api.github.com/repos/kahikatea-2016/harvestr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kahikatea-2016/harvestr/statuses/{sha}","languages_url":"https://api.github.com/repos/kahikatea-2016/harvestr/languages","stargazers_url":"https://api.github.com/repos/kahikatea-2016/harvestr/stargazers","contributors_url":"https://api.github.com/repos/kahikatea-2016/harvestr/contributors","subscribers_url":"https://api.github.com/repos/kahikatea-2016/harvestr/subscribers","subscription_url":"https://api.github.com/repos/kahikatea-2016/harvestr/subscription","commits_url":"https://api.github.com/repos/kahikatea-2016/harvestr/commits{/sha}","git_commits_url":"https://api.github.com/repos/kahikatea-2016/harvestr/git/commits{/sha}","comments_url":"https://api.github.com/repos/kahikatea-2016/harvestr/comments{/number}","issue_comment_url":"https://api.github.com/repos/kahikatea-2016/harvestr/issues/comments{/number}","contents_url":"https://api.github.com/repos/kahikatea-2016/harvestr/contents/{+path}","compare_url":"https://api.github.com/repos/kahikatea-2016/harvestr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kahikatea-2016/harvestr/merges","archive_url":"https://api.github.com/repos/kahikatea-2016/harvestr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kahikatea-2016/harvestr/downloads","issues_url":"https://api.github.com/repos/kahikatea-2016/harvestr/issues{/number}","pulls_url":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls{/number}","milestones_url":"https://api.github.com/repos/kahikatea-2016/harvestr/milestones{/number}","notifications_url":"https://api.github.com/repos/kahikatea-2016/harvestr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kahikatea-2016/harvestr/labels{/name}","releases_url":"https://api.github.com/repos/kahikatea-2016/harvestr/releases{/id}","deployments_url":"https://api.github.com/repos/kahikatea-2016/harvestr/deployments","created_at":"2016-10-19T05:01:53Z","updated_at":"2016-10-22T02:39:18Z","pushed_at":"2016-10-23T22:05:03Z","git_url":"git://github.com/kahikatea-2016/harvestr.git","ssh_url":"git@github.com:kahikatea-2016/harvestr.git","clone_url":"https://github.com/kahikatea-2016/harvestr.git","svn_url":"https://github.com/kahikatea-2016/harvestr","homepage":null,"size":10428,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":0,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/81"},"html":{"href":"https://github.com/kahikatea-2016/harvestr/pull/81"},"issue":{"href":"https://api.github.com/repos/kahikatea-2016/harvestr/issues/81"},"comments":{"href":"https://api.github.com/repos/kahikatea-2016/harvestr/issues/81/comments"},"review_comments":{"href":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/81/comments"},"review_comment":{"href":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kahikatea-2016/harvestr/pulls/81/commits"},"statuses":{"href":"https://api.github.com/repos/kahikatea-2016/harvestr/statuses/e1e1a938f7f33063b4d15392121fb74e96bcfada"}}}}
{"actor":{"display_login":"richchurcher"}}