{"action":"created","comment":{"url":"https://api.github.com/repos/andela/rivendell-ah/pulls/comments/210678736","pull_request_review_id":146945877,"id":210678736,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMDY3ODczNg==","diff_hunk":"@@ -0,0 +1,137 @@\n+import slugCreate from 'slug';\n+import { Router } from 'express';\n+import models from '../../models';\n+import auth from '../../middleware/AuthMiddleware';\n+\n+const { Article, User } = models;\n+const router = Router();\n+\n+router.post('/articles', auth.authenticateUser, (req, res, next) => {\n+  const {\n+    title, description, body,\n+  } = req.body.article;\n+\n+  // generating a unique slug\n+  const timeStamp = Date.now();\n+  const slug = slugCreate(`${title} ${req.body.decoded.username} ${timeStamp}`);\n+\n+  const authorId = req.body.decoded.id;\n+\n+\n+  Article.create({\n+    slug, title, description, body, authorId,\n+  })\n+    .then((article) => {\n+      res.status(201).json({\n+        article: {\n+          title: article.title,\n+          description: article.description,\n+          body: article.body,\n+          slug,\n+        },\n+        message: 'Article Sucessfully Created',\n+      });\n+    })\n+    .catch(next);\n+});\n+\n+router.get('/articles/:slug', (req, res, next) => {\n+  Article.find({ where: { slug: req.params.slug } })\n+    .then((article) => {\n+      if (article) {\n+        User.find({ where: { id: article.authorId } })\n+          .then((user) => {\n+            res.status(201).json({\n+              article: {\n+                slug: article.slug,\n+                title: article.title,\n+                description: article.description,\n+                body: article.body,\n+                author: user.username,\n+              },\n+              message: 'Article Found',\n+            });\n+          })\n+          .catch(next);\n+      } else {\n+        res.status(404).json({\n+          status: 'fail',\n+          message: 'Article not found',\n+        });\n+      }\n+    })\n+    .catch(next);\n+});\n+\n+router.put('/articles/:slug', auth.authenticateUser, (req, res, next) => {\n+  const {\n+    title, description, body,\n+  } = req.body.article;\n+\n+  Article.find({ where: { slug: req.params.slug } })\n+    .then((article) => {\n+      if (article) {\n+        const updatedArticle = article;\n+        updatedArticle.title = title !== undefined ? title : article.title;\n+        updatedArticle.description = description !== undefined ? description : article.description;","path":"routes/api/articles.js","position":76,"original_position":76,"commit_id":"40bc6715af713adf452aeaa249497016e37f54fc","original_commit_id":"40bc6715af713adf452aeaa249497016e37f54fc","user":{"login":"houndci-bot","id":6697940,"node_id":"MDQ6VXNlcjY2OTc5NDA=","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":"Line 76 exceeds the maximum line length of 80  max-len","created_at":"2018-08-16T17:29:02Z","updated_at":"2018-08-16T17:29:03Z","html_url":"https://github.com/andela/rivendell-ah/pull/38#discussion_r210678736","pull_request_url":"https://api.github.com/repos/andela/rivendell-ah/pulls/38","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/comments/210678736"},"html":{"href":"https://github.com/andela/rivendell-ah/pull/38#discussion_r210678736"},"pull_request":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/38"}}},"pull_request":{"url":"https://api.github.com/repos/andela/rivendell-ah/pulls/38","id":208930570,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA4OTMwNTcw","html_url":"https://github.com/andela/rivendell-ah/pull/38","diff_url":"https://github.com/andela/rivendell-ah/pull/38.diff","patch_url":"https://github.com/andela/rivendell-ah/pull/38.patch","issue_url":"https://api.github.com/repos/andela/rivendell-ah/issues/38","number":38,"state":"open","locked":false,"title":"#159204699 User rating articles","user":{"login":"tutugodfrey","id":30448913,"node_id":"MDQ6VXNlcjMwNDQ4OTEz","avatar_url":"https://avatars1.githubusercontent.com/u/30448913?v=4","gravatar_id":"","url":"https://api.github.com/users/tutugodfrey","html_url":"https://github.com/tutugodfrey","followers_url":"https://api.github.com/users/tutugodfrey/followers","following_url":"https://api.github.com/users/tutugodfrey/following{/other_user}","gists_url":"https://api.github.com/users/tutugodfrey/gists{/gist_id}","starred_url":"https://api.github.com/users/tutugodfrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tutugodfrey/subscriptions","organizations_url":"https://api.github.com/users/tutugodfrey/orgs","repos_url":"https://api.github.com/users/tutugodfrey/repos","events_url":"https://api.github.com/users/tutugodfrey/events{/privacy}","received_events_url":"https://api.github.com/users/tutugodfrey/received_events","type":"User","site_admin":false},"body":"\r\n#### What does this PR do?\r\n- add the implementation for users to rate articles\r\n\r\n#### Description of Task to be completed?\r\n- write tests for the requirements for rating articles\r\n- create a model (table) for storing rating data\r\n- add routes to rating the articles by Id\r\n- a middlewares function for abstraction\r\n- add the controller to save ratings to the database\r\n- add a route for getting article rating by id\r\n- add a test for the get route\r\n\r\n#### How should this be manually tested?\r\n- clone the repository from https://github.com/andela/rivendell-ah\r\n- run `npm install` and set up the environment variable based on the example in sample-env file\r\n- run `npm test` to run test you can also interact with the application at\r\n- http://localhost:3000/articles/rating/{articleId}?rating={ratingValue}\r\n\r\n#### Any background context you want to provide?\r\n- rating an article require Authorization token be provided in header\r\n\r\n```\r\nFor reviewers:\r\nfiles to review are  as listed below\r\n/server/tests/article.tests.js\r\n/server/controllers/articleControllers.js\r\nreview article rateArticle controller and getArticleRating in the articles controller\r\nother modifitation in the article controller will be made by Jane when she is done with her feature.\r\n\r\n```\r\n#### What are the relevant pivotal tracker stories?\r\n#159204699\r\n\r\n#### Screenshots (if appropriate)\r\n![image](https://user-images.githubusercontent.com/30448913/44220198-d2855880-a175-11e8-9f68-69b657620fd7.png)\r\n![image](https://user-images.githubusercontent.com/30448913/44220209-da44fd00-a175-11e8-9fca-cec22bedbc0d.png)\r\n![image](https://user-images.githubusercontent.com/30448913/44220217-e0d37480-a175-11e8-8428-b1c98d0a3ade.png)\r\n![image](https://user-images.githubusercontent.com/30448913/44220224-e630bf00-a175-11e8-9e83-413d85026493.png)\r\n![image](https://user-images.githubusercontent.com/30448913/44220238-edf06380-a175-11e8-8d06-6f851b84af32.png)\r\n![image](https://user-images.githubusercontent.com/30448913/44220248-f5177180-a175-11e8-8afa-a6361e31c5b2.png)\r\n\r\n#### Questions:\r\nN/A\r\n","created_at":"2018-08-16T17:28:32Z","updated_at":"2018-08-16T17:29:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e3a5dab277b31c32ab80fb19902eb970559cdb5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela/rivendell-ah/pulls/38/commits","review_comments_url":"https://api.github.com/repos/andela/rivendell-ah/pulls/38/comments","review_comment_url":"https://api.github.com/repos/andela/rivendell-ah/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela/rivendell-ah/issues/38/comments","statuses_url":"https://api.github.com/repos/andela/rivendell-ah/statuses/40bc6715af713adf452aeaa249497016e37f54fc","head":{"label":"andela:feature/159204699/users-rate-article","ref":"feature/159204699/users-rate-article","sha":"40bc6715af713adf452aeaa249497016e37f54fc","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":141551362,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE1NTEzNjI=","name":"rivendell-ah","full_name":"andela/rivendell-ah","owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/andela/rivendell-ah","description":null,"fork":false,"url":"https://api.github.com/repos/andela/rivendell-ah","forks_url":"https://api.github.com/repos/andela/rivendell-ah/forks","keys_url":"https://api.github.com/repos/andela/rivendell-ah/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/rivendell-ah/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/rivendell-ah/teams","hooks_url":"https://api.github.com/repos/andela/rivendell-ah/hooks","issue_events_url":"https://api.github.com/repos/andela/rivendell-ah/issues/events{/number}","events_url":"https://api.github.com/repos/andela/rivendell-ah/events","assignees_url":"https://api.github.com/repos/andela/rivendell-ah/assignees{/user}","branches_url":"https://api.github.com/repos/andela/rivendell-ah/branches{/branch}","tags_url":"https://api.github.com/repos/andela/rivendell-ah/tags","blobs_url":"https://api.github.com/repos/andela/rivendell-ah/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/rivendell-ah/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/rivendell-ah/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/rivendell-ah/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/rivendell-ah/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/rivendell-ah/languages","stargazers_url":"https://api.github.com/repos/andela/rivendell-ah/stargazers","contributors_url":"https://api.github.com/repos/andela/rivendell-ah/contributors","subscribers_url":"https://api.github.com/repos/andela/rivendell-ah/subscribers","subscription_url":"https://api.github.com/repos/andela/rivendell-ah/subscription","commits_url":"https://api.github.com/repos/andela/rivendell-ah/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/rivendell-ah/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/rivendell-ah/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/rivendell-ah/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/rivendell-ah/contents/{+path}","compare_url":"https://api.github.com/repos/andela/rivendell-ah/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/rivendell-ah/merges","archive_url":"https://api.github.com/repos/andela/rivendell-ah/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/rivendell-ah/downloads","issues_url":"https://api.github.com/repos/andela/rivendell-ah/issues{/number}","pulls_url":"https://api.github.com/repos/andela/rivendell-ah/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/rivendell-ah/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/rivendell-ah/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/rivendell-ah/labels{/name}","releases_url":"https://api.github.com/repos/andela/rivendell-ah/releases{/id}","deployments_url":"https://api.github.com/repos/andela/rivendell-ah/deployments","created_at":"2018-07-19T08:51:46Z","updated_at":"2018-08-16T08:46:38Z","pushed_at":"2018-08-16T17:28:32Z","git_url":"git://github.com/andela/rivendell-ah.git","ssh_url":"git@github.com:andela/rivendell-ah.git","clone_url":"https://github.com/andela/rivendell-ah.git","svn_url":"https://github.com/andela/rivendell-ah","homepage":null,"size":326,"stargazers_count":0,"watchers_count":0,"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":4,"license":null,"forks":0,"open_issues":4,"watchers":0,"default_branch":"staging"}},"base":{"label":"andela:staging","ref":"staging","sha":"30a7f200b7ed507b762803f3ec2e144a43989856","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":141551362,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE1NTEzNjI=","name":"rivendell-ah","full_name":"andela/rivendell-ah","owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/andela/rivendell-ah","description":null,"fork":false,"url":"https://api.github.com/repos/andela/rivendell-ah","forks_url":"https://api.github.com/repos/andela/rivendell-ah/forks","keys_url":"https://api.github.com/repos/andela/rivendell-ah/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/rivendell-ah/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/rivendell-ah/teams","hooks_url":"https://api.github.com/repos/andela/rivendell-ah/hooks","issue_events_url":"https://api.github.com/repos/andela/rivendell-ah/issues/events{/number}","events_url":"https://api.github.com/repos/andela/rivendell-ah/events","assignees_url":"https://api.github.com/repos/andela/rivendell-ah/assignees{/user}","branches_url":"https://api.github.com/repos/andela/rivendell-ah/branches{/branch}","tags_url":"https://api.github.com/repos/andela/rivendell-ah/tags","blobs_url":"https://api.github.com/repos/andela/rivendell-ah/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/rivendell-ah/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/rivendell-ah/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/rivendell-ah/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/rivendell-ah/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/rivendell-ah/languages","stargazers_url":"https://api.github.com/repos/andela/rivendell-ah/stargazers","contributors_url":"https://api.github.com/repos/andela/rivendell-ah/contributors","subscribers_url":"https://api.github.com/repos/andela/rivendell-ah/subscribers","subscription_url":"https://api.github.com/repos/andela/rivendell-ah/subscription","commits_url":"https://api.github.com/repos/andela/rivendell-ah/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/rivendell-ah/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/rivendell-ah/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/rivendell-ah/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/rivendell-ah/contents/{+path}","compare_url":"https://api.github.com/repos/andela/rivendell-ah/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/rivendell-ah/merges","archive_url":"https://api.github.com/repos/andela/rivendell-ah/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/rivendell-ah/downloads","issues_url":"https://api.github.com/repos/andela/rivendell-ah/issues{/number}","pulls_url":"https://api.github.com/repos/andela/rivendell-ah/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/rivendell-ah/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/rivendell-ah/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/rivendell-ah/labels{/name}","releases_url":"https://api.github.com/repos/andela/rivendell-ah/releases{/id}","deployments_url":"https://api.github.com/repos/andela/rivendell-ah/deployments","created_at":"2018-07-19T08:51:46Z","updated_at":"2018-08-16T08:46:38Z","pushed_at":"2018-08-16T17:28:32Z","git_url":"git://github.com/andela/rivendell-ah.git","ssh_url":"git@github.com:andela/rivendell-ah.git","clone_url":"https://github.com/andela/rivendell-ah.git","svn_url":"https://github.com/andela/rivendell-ah","homepage":null,"size":326,"stargazers_count":0,"watchers_count":0,"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":4,"license":null,"forks":0,"open_issues":4,"watchers":0,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/38"},"html":{"href":"https://github.com/andela/rivendell-ah/pull/38"},"issue":{"href":"https://api.github.com/repos/andela/rivendell-ah/issues/38"},"comments":{"href":"https://api.github.com/repos/andela/rivendell-ah/issues/38/comments"},"review_comments":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/38/comments"},"review_comment":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/38/commits"},"statuses":{"href":"https://api.github.com/repos/andela/rivendell-ah/statuses/40bc6715af713adf452aeaa249497016e37f54fc"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"houndci-bot"}}