{"action":"created","comment":{"url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/comments/187466494","pull_request_review_id":119255510,"id":187466494,"diff_hunk":"@@ -0,0 +1,201 @@\n+import models from '../models';\n+import { filterOrderDetail } from '../common/filter';\n+\n+const mealOrderController = {\n+  \n+  // Place an order\n+\n+  makeOrder(req, res) {\n+    const userId = req.decoded.id;\n+    const hours = new Date().getHours();\n+    const minutes = new Date().getMinutes();\n+    const time = `${hours}:${minutes}`;\n+    const date = new Date().toDateString();\n+\n+    const {\n+      catererId,\n+      mealId,\n+      quantity,\n+      deliveryAddress,\n+    } = req.body;\n+\n+    if (Number(hours) < 8) {\n+      return res.status(404).send({ message: 'You cannot place an order yet' });\n+    }\n+    if (Number(hours) > 16) {\n+      return res.status(404).send({ message: 'You cannot place any order for today' });\n+    }\n+    if (Number.isNaN(Number(mealId))) {\n+      return res.status(404).send({ message: 'Provide a valid menu id' });\n+    }\n+    if (Number.isNaN(Number(catererId))) {\n+      return res.status(404).send({ message: 'Provide a valid caterer id' });\n+    }\n+    if (Number.isNaN(Number(quantity))) {\n+      return res.status(404).send({ message: 'Provide a valid quantity value' });\n+    }\n+    if (Number(quantity) > 20) {\n+      return res.status(404).send({ message: 'Please select a quantity that is less than or equal to 20' });\n+    }\n+    if (Number(quantity) < 1) {\n+      return res.status(404).send({ message: 'Please select a quantity that is greater than or equal to 1' });\n+    }\n+    if (deliveryAddress && ((/^ *$/.test(deliveryAddress) === true) || (/[<>]/.test(deliveryAddress) === true) || typeof deliveryAddress !== 'string')) {\n+      return res.status(400).send({ message: 'Please provide a valid address' });\n+    }\n+\n+    models.menu\n+      .findOne({ where: { date } })\n+      .then((menu) => {\n+        if (!menu) {\n+          return res.status(404).send({ message: 'The menu for today has not been set yet' });\n+        }\n+      })\n+      .catch(err => res.status(500).send({ message: err.message }));\n+\n+    return models.meal\n+      .findOne({\n+        where: {\n+          id: mealId,\n+        },\n+      })\n+      .then((meal) => {\n+        if (!meal) {\n+          return res.status(404).send({ message: 'Meal not found' });\n+        }\n+        const orderedMeal = meal;\n+        return orderedMeal;\n+      })\n+      .then((orderedMeal) => {\n+        models.order\n+          .create({\n+            customerId: userId,\n+            catererId,\n+            time,\n+            mealName: orderedMeal.name,\n+            mealId: orderedMeal.id,\n+            mealPrice: orderedMeal.price,\n+            quantity,\n+            totalCost: (Number(orderedMeal.price) * Number(quantity)),\n+            deliveryAddress,\n+          })\n+          .then(order => res.status(201).send({ message: 'Order Placed successfully', data: order }))\n+          .catch(err => res.status(500).send({ message: err.message }));\n+      })\n+      .catch(err => res.status(500).send({ message: err.message }));\n+  },\n+\n+  // Get all order\n+\n+  getOrder(req, res) {\n+    const catererId = req.decoded.id;\n+    const date = new Date().toDateString();\n+\n+    return models.order\n+      .findAll({\n+        where: {\n+          catererId,\n+          date,\n+        },\n+        include: [\n+          {\n+            model: models.user,\n+            as: 'user',\n+            attributes: ['fullName', 'email', 'phoneNumber', 'address'],\n+          },\n+        ],\n+      })\n+      .then((meal) => {\n+        if (meal.length === 0) {\n+          return res.status(404).send({ message: 'You done have any order yet' });\n+        }\n+        const filteredOrder = [];\n+        meal.forEach((meals) => {\n+          const filter = filterOrderDetail(meals);\n+          filteredOrder.push(filter);\n+        });\n+        return res.status(200).send({ message: 'You have the following orders', data: filteredOrder });\n+      })\n+      .catch(err => res.status(500).send({ message: err.message }));","path":"server/controllers/orderController.js","position":119,"original_position":119,"commit_id":"d99b3eddebc34165731daa9cdcb6e50c6a75c85f","original_commit_id":"d99b3eddebc34165731daa9cdcb6e50c6a75c85f","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').","created_at":"2018-05-10T21:32:13Z","updated_at":"2018-05-10T21:32:14Z","html_url":"https://github.com/Nkemjiks/book-a-meal-app/pull/39#discussion_r187466494","pull_request_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/39","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/comments/187466494"},"html":{"href":"https://github.com/Nkemjiks/book-a-meal-app/pull/39#discussion_r187466494"},"pull_request":{"href":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/39","id":187252757,"html_url":"https://github.com/Nkemjiks/book-a-meal-app/pull/39","diff_url":"https://github.com/Nkemjiks/book-a-meal-app/pull/39.diff","patch_url":"https://github.com/Nkemjiks/book-a-meal-app/pull/39.patch","issue_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/issues/39","number":39,"state":"open","locked":false,"title":"Implement the User Sign Up test","user":{"login":"Nkemjiks","id":32465536,"avatar_url":"https://avatars0.githubusercontent.com/u/32465536?v=4","gravatar_id":"","url":"https://api.github.com/users/Nkemjiks","html_url":"https://github.com/Nkemjiks","followers_url":"https://api.github.com/users/Nkemjiks/followers","following_url":"https://api.github.com/users/Nkemjiks/following{/other_user}","gists_url":"https://api.github.com/users/Nkemjiks/gists{/gist_id}","starred_url":"https://api.github.com/users/Nkemjiks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nkemjiks/subscriptions","organizations_url":"https://api.github.com/users/Nkemjiks/orgs","repos_url":"https://api.github.com/users/Nkemjiks/repos","events_url":"https://api.github.com/users/Nkemjiks/events{/privacy}","received_events_url":"https://api.github.com/users/Nkemjiks/received_events","type":"User","site_admin":false},"body":"- Wrote test cases for the signup controller\r\n- worked on LFA feedback\r\n\r\n[Finishes #157443544]","created_at":"2018-05-10T17:18:16Z","updated_at":"2018-05-10T21:32:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"35e6b91222dc80db44c8cbd6bf584ec366658f6a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/39/commits","review_comments_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/39/comments","review_comment_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/issues/39/comments","statuses_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/statuses/d99b3eddebc34165731daa9cdcb6e50c6a75c85f","head":{"label":"Nkemjiks:ft-user-signup-test-157443544","ref":"ft-user-signup-test-157443544","sha":"d99b3eddebc34165731daa9cdcb6e50c6a75c85f","user":{"login":"Nkemjiks","id":32465536,"avatar_url":"https://avatars0.githubusercontent.com/u/32465536?v=4","gravatar_id":"","url":"https://api.github.com/users/Nkemjiks","html_url":"https://github.com/Nkemjiks","followers_url":"https://api.github.com/users/Nkemjiks/followers","following_url":"https://api.github.com/users/Nkemjiks/following{/other_user}","gists_url":"https://api.github.com/users/Nkemjiks/gists{/gist_id}","starred_url":"https://api.github.com/users/Nkemjiks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nkemjiks/subscriptions","organizations_url":"https://api.github.com/users/Nkemjiks/orgs","repos_url":"https://api.github.com/users/Nkemjiks/repos","events_url":"https://api.github.com/users/Nkemjiks/events{/privacy}","received_events_url":"https://api.github.com/users/Nkemjiks/received_events","type":"User","site_admin":false},"repo":{"id":129936217,"name":"book-a-meal-app","full_name":"Nkemjiks/book-a-meal-app","owner":{"login":"Nkemjiks","id":32465536,"avatar_url":"https://avatars0.githubusercontent.com/u/32465536?v=4","gravatar_id":"","url":"https://api.github.com/users/Nkemjiks","html_url":"https://github.com/Nkemjiks","followers_url":"https://api.github.com/users/Nkemjiks/followers","following_url":"https://api.github.com/users/Nkemjiks/following{/other_user}","gists_url":"https://api.github.com/users/Nkemjiks/gists{/gist_id}","starred_url":"https://api.github.com/users/Nkemjiks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nkemjiks/subscriptions","organizations_url":"https://api.github.com/users/Nkemjiks/orgs","repos_url":"https://api.github.com/users/Nkemjiks/repos","events_url":"https://api.github.com/users/Nkemjiks/events{/privacy}","received_events_url":"https://api.github.com/users/Nkemjiks/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Nkemjiks/book-a-meal-app","description":"Book-A-Meal is an application that allows customers to make food orders and helps the food vendor know what the customers want to eat. ","fork":false,"url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app","forks_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/forks","keys_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/teams","hooks_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/hooks","issue_events_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/issues/events{/number}","events_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/events","assignees_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/assignees{/user}","branches_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/branches{/branch}","tags_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/tags","blobs_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/statuses/{sha}","languages_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/languages","stargazers_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/stargazers","contributors_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/contributors","subscribers_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/subscribers","subscription_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/subscription","commits_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/contents/{+path}","compare_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/merges","archive_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/downloads","issues_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/issues{/number}","pulls_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls{/number}","milestones_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/milestones{/number}","notifications_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/labels{/name}","releases_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/releases{/id}","deployments_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/deployments","created_at":"2018-04-17T16:44:32Z","updated_at":"2018-05-02T08:04:34Z","pushed_at":"2018-05-10T21:31:45Z","git_url":"git://github.com/Nkemjiks/book-a-meal-app.git","ssh_url":"git@github.com:Nkemjiks/book-a-meal-app.git","clone_url":"https://github.com/Nkemjiks/book-a-meal-app.git","svn_url":"https://github.com/Nkemjiks/book-a-meal-app","homepage":null,"size":282,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":0,"default_branch":"development"}},"base":{"label":"Nkemjiks:development","ref":"development","sha":"dccc747a31ff9a9da8909400776983fbf7ea8751","user":{"login":"Nkemjiks","id":32465536,"avatar_url":"https://avatars0.githubusercontent.com/u/32465536?v=4","gravatar_id":"","url":"https://api.github.com/users/Nkemjiks","html_url":"https://github.com/Nkemjiks","followers_url":"https://api.github.com/users/Nkemjiks/followers","following_url":"https://api.github.com/users/Nkemjiks/following{/other_user}","gists_url":"https://api.github.com/users/Nkemjiks/gists{/gist_id}","starred_url":"https://api.github.com/users/Nkemjiks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nkemjiks/subscriptions","organizations_url":"https://api.github.com/users/Nkemjiks/orgs","repos_url":"https://api.github.com/users/Nkemjiks/repos","events_url":"https://api.github.com/users/Nkemjiks/events{/privacy}","received_events_url":"https://api.github.com/users/Nkemjiks/received_events","type":"User","site_admin":false},"repo":{"id":129936217,"name":"book-a-meal-app","full_name":"Nkemjiks/book-a-meal-app","owner":{"login":"Nkemjiks","id":32465536,"avatar_url":"https://avatars0.githubusercontent.com/u/32465536?v=4","gravatar_id":"","url":"https://api.github.com/users/Nkemjiks","html_url":"https://github.com/Nkemjiks","followers_url":"https://api.github.com/users/Nkemjiks/followers","following_url":"https://api.github.com/users/Nkemjiks/following{/other_user}","gists_url":"https://api.github.com/users/Nkemjiks/gists{/gist_id}","starred_url":"https://api.github.com/users/Nkemjiks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nkemjiks/subscriptions","organizations_url":"https://api.github.com/users/Nkemjiks/orgs","repos_url":"https://api.github.com/users/Nkemjiks/repos","events_url":"https://api.github.com/users/Nkemjiks/events{/privacy}","received_events_url":"https://api.github.com/users/Nkemjiks/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Nkemjiks/book-a-meal-app","description":"Book-A-Meal is an application that allows customers to make food orders and helps the food vendor know what the customers want to eat. ","fork":false,"url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app","forks_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/forks","keys_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/teams","hooks_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/hooks","issue_events_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/issues/events{/number}","events_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/events","assignees_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/assignees{/user}","branches_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/branches{/branch}","tags_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/tags","blobs_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/statuses/{sha}","languages_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/languages","stargazers_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/stargazers","contributors_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/contributors","subscribers_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/subscribers","subscription_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/subscription","commits_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/contents/{+path}","compare_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/merges","archive_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/downloads","issues_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/issues{/number}","pulls_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls{/number}","milestones_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/milestones{/number}","notifications_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/labels{/name}","releases_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/releases{/id}","deployments_url":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/deployments","created_at":"2018-04-17T16:44:32Z","updated_at":"2018-05-02T08:04:34Z","pushed_at":"2018-05-10T21:31:45Z","git_url":"git://github.com/Nkemjiks/book-a-meal-app.git","ssh_url":"git@github.com:Nkemjiks/book-a-meal-app.git","clone_url":"https://github.com/Nkemjiks/book-a-meal-app.git","svn_url":"https://github.com/Nkemjiks/book-a-meal-app","homepage":null,"size":282,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":0,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/39"},"html":{"href":"https://github.com/Nkemjiks/book-a-meal-app/pull/39"},"issue":{"href":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/issues/39"},"comments":{"href":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/Nkemjiks/book-a-meal-app/statuses/d99b3eddebc34165731daa9cdcb6e50c6a75c85f"}},"author_association":"OWNER"}}
{"actor":{"display_login":"houndci-bot"}}