{"action":"created","comment":{"url":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/comments/199848023","pull_request_review_id":134048011,"id":199848023,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTg0ODAyMw==","diff_hunk":"@@ -13,118 +15,138 @@ class rideOfferController {\n    * @return{json} registered ride offer details\n    */\n   static createRideOffer(req, res) {\n-    rideOffer.push({\n-      id: rideOffer.length + 1,\n-      title: req.body.title.toLowerCase(),\n-      driverName: req.body.driverName.toLowerCase(),\n-      destination: req.body.destination.toLowerCase(),\n-      depart: req.body.depart.toLowerCase(),\n-      date: req.body.date,\n-      fee: req.body.fee\n-    });\n-    const offerId = rideOffer.length;\n-    const offer = rideOffer.find(oneRide => oneRide.id === offerId);\n-    return res.status(201).json({\n-      message: 'Ride offer created successfully',\n-      offer,\n-      success: true\n-    });\n-  }\n-\n-  /**\n-   * @description - Get all ride offers\n-   * @param{Object} req - api request\n-   * @param{Object} res - route response\n-   * @return{json} registered ride offer details\n-   */\n-  static getAllRideOffer(req, res) {\n-    if (rideOffer.length < 1) {\n-      return res.status(200).json({\n-        message: 'No ride Offer found!',\n-        success: true\n+    const createRide = `INSERT INTO Ride_offers (userId, message, destination, \n+                        depart, time, date, cost, seats)\n+                        VALUES ($1, $2, $3, $4, $5, $6, $7, $8)\n+                        RETURNING *`;\n+    clientPool.connect()\n+      .then((client) => {\n+        client.query({\n+          text: createRide,\n+          values: [req.userData, req.body.message, req.body.destination, req.body.depart,\n+            req.body.time, req.body.date, req.body.cost, req.body.seats\n+          ]\n+        })\n+          .then((createdRide) => {\n+            client.release();\n+            res.status(201).json({\n+              message: 'Your ride offer is created successfully',\n+              data: {\n+                rideId: createdRide.rows[0].rideId,\n+                message: createdRide.rows[0].message,\n+                destination: createdRide.rows[0].destination,\n+                departureLocation: createdRide.rows[0].depart,\n+                time: createdRide.rows[0].time,\n+                date: createdRide.rows[0].date,\n+                cost: createdRide.rows[0].cost,\n+                seats: createdRide.rows[0].seats,\n+                userId: createdRide.rows[0].userId,\n+              },\n+            });\n+          })\n+          .catch((err) => {\n+            client.release();\n+            res.status(400).send({\n+              message: err.errors ? err.errors[0].message : err.message\n+            });\n+          });\n       });\n-    }\n-    return res.status(200).json({\n-      rideOffer,\n-      success: true\n-    });\n   }\n ","path":"server/controllers/rideOffer.js","position":86,"original_position":86,"commit_id":"09396f265a703507a6b3a114e5b7af455cfcbf53","original_commit_id":"09396f265a703507a6b3a114e5b7af455cfcbf53","user":{"login":"andela-gesit","id":20546118,"node_id":"MDQ6VXNlcjIwNTQ2MTE4","avatar_url":"https://avatars0.githubusercontent.com/u/20546118?v=4","gravatar_id":"","url":"https://api.github.com/users/andela-gesit","html_url":"https://github.com/andela-gesit","followers_url":"https://api.github.com/users/andela-gesit/followers","following_url":"https://api.github.com/users/andela-gesit/following{/other_user}","gists_url":"https://api.github.com/users/andela-gesit/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-gesit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-gesit/subscriptions","organizations_url":"https://api.github.com/users/andela-gesit/orgs","repos_url":"https://api.github.com/users/andela-gesit/repos","events_url":"https://api.github.com/users/andela-gesit/events{/privacy}","received_events_url":"https://api.github.com/users/andela-gesit/received_events","type":"User","site_admin":false},"body":"Remove commented out logic from your code.","created_at":"2018-07-03T15:20:48Z","updated_at":"2018-07-03T15:23:51Z","html_url":"https://github.com/d-beloved/Ride-my-way/pull/11#discussion_r199848023","pull_request_url":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/11","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/comments/199848023"},"html":{"href":"https://github.com/d-beloved/Ride-my-way/pull/11#discussion_r199848023"},"pull_request":{"href":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/11","id":198996278,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4OTk2Mjc4","html_url":"https://github.com/d-beloved/Ride-my-way/pull/11","diff_url":"https://github.com/d-beloved/Ride-my-way/pull/11.diff","patch_url":"https://github.com/d-beloved/Ride-my-way/pull/11.patch","issue_url":"https://api.github.com/repos/d-beloved/Ride-my-way/issues/11","number":11,"state":"open","locked":false,"title":"Ft create ride offer db endpoint 158666012","user":{"login":"d-beloved","id":26516851,"node_id":"MDQ6VXNlcjI2NTE2ODUx","avatar_url":"https://avatars0.githubusercontent.com/u/26516851?v=4","gravatar_id":"","url":"https://api.github.com/users/d-beloved","html_url":"https://github.com/d-beloved","followers_url":"https://api.github.com/users/d-beloved/followers","following_url":"https://api.github.com/users/d-beloved/following{/other_user}","gists_url":"https://api.github.com/users/d-beloved/gists{/gist_id}","starred_url":"https://api.github.com/users/d-beloved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d-beloved/subscriptions","organizations_url":"https://api.github.com/users/d-beloved/orgs","repos_url":"https://api.github.com/users/d-beloved/repos","events_url":"https://api.github.com/users/d-beloved/events{/privacy}","received_events_url":"https://api.github.com/users/d-beloved/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\nAdds the endpoint to create ride offers\r\n\r\n### Description of Task to be completed?\r\nA signed in user will be able to create a ride offer passing in various parameters\r\n\r\n### How should this be manually tested?\r\nrun `npm run start:dev` then visit the `localhost:3110/api/v1/users/rides`\r\n","created_at":"2018-07-03T15:09:38Z","updated_at":"2018-07-03T15:23:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bcd21d8387c87f850d481f2ae9ca4d484fd462e4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/11/commits","review_comments_url":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/11/comments","review_comment_url":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/comments{/number}","comments_url":"https://api.github.com/repos/d-beloved/Ride-my-way/issues/11/comments","statuses_url":"https://api.github.com/repos/d-beloved/Ride-my-way/statuses/09396f265a703507a6b3a114e5b7af455cfcbf53","head":{"label":"d-beloved:ft-create-ride-offer-db-endpoint-158666012","ref":"ft-create-ride-offer-db-endpoint-158666012","sha":"09396f265a703507a6b3a114e5b7af455cfcbf53","user":{"login":"d-beloved","id":26516851,"node_id":"MDQ6VXNlcjI2NTE2ODUx","avatar_url":"https://avatars0.githubusercontent.com/u/26516851?v=4","gravatar_id":"","url":"https://api.github.com/users/d-beloved","html_url":"https://github.com/d-beloved","followers_url":"https://api.github.com/users/d-beloved/followers","following_url":"https://api.github.com/users/d-beloved/following{/other_user}","gists_url":"https://api.github.com/users/d-beloved/gists{/gist_id}","starred_url":"https://api.github.com/users/d-beloved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d-beloved/subscriptions","organizations_url":"https://api.github.com/users/d-beloved/orgs","repos_url":"https://api.github.com/users/d-beloved/repos","events_url":"https://api.github.com/users/d-beloved/events{/privacy}","received_events_url":"https://api.github.com/users/d-beloved/received_events","type":"User","site_admin":false},"repo":{"id":136992653,"node_id":"MDEwOlJlcG9zaXRvcnkxMzY5OTI2NTM=","name":"Ride-my-way","full_name":"d-beloved/Ride-my-way","owner":{"login":"d-beloved","id":26516851,"node_id":"MDQ6VXNlcjI2NTE2ODUx","avatar_url":"https://avatars0.githubusercontent.com/u/26516851?v=4","gravatar_id":"","url":"https://api.github.com/users/d-beloved","html_url":"https://github.com/d-beloved","followers_url":"https://api.github.com/users/d-beloved/followers","following_url":"https://api.github.com/users/d-beloved/following{/other_user}","gists_url":"https://api.github.com/users/d-beloved/gists{/gist_id}","starred_url":"https://api.github.com/users/d-beloved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d-beloved/subscriptions","organizations_url":"https://api.github.com/users/d-beloved/orgs","repos_url":"https://api.github.com/users/d-beloved/repos","events_url":"https://api.github.com/users/d-beloved/events{/privacy}","received_events_url":"https://api.github.com/users/d-beloved/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/d-beloved/Ride-my-way","description":"A carpooling application that provides drivers with the ability to create ride offers and passengers to join available ride offers","fork":false,"url":"https://api.github.com/repos/d-beloved/Ride-my-way","forks_url":"https://api.github.com/repos/d-beloved/Ride-my-way/forks","keys_url":"https://api.github.com/repos/d-beloved/Ride-my-way/keys{/key_id}","collaborators_url":"https://api.github.com/repos/d-beloved/Ride-my-way/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/d-beloved/Ride-my-way/teams","hooks_url":"https://api.github.com/repos/d-beloved/Ride-my-way/hooks","issue_events_url":"https://api.github.com/repos/d-beloved/Ride-my-way/issues/events{/number}","events_url":"https://api.github.com/repos/d-beloved/Ride-my-way/events","assignees_url":"https://api.github.com/repos/d-beloved/Ride-my-way/assignees{/user}","branches_url":"https://api.github.com/repos/d-beloved/Ride-my-way/branches{/branch}","tags_url":"https://api.github.com/repos/d-beloved/Ride-my-way/tags","blobs_url":"https://api.github.com/repos/d-beloved/Ride-my-way/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/d-beloved/Ride-my-way/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/d-beloved/Ride-my-way/git/refs{/sha}","trees_url":"https://api.github.com/repos/d-beloved/Ride-my-way/git/trees{/sha}","statuses_url":"https://api.github.com/repos/d-beloved/Ride-my-way/statuses/{sha}","languages_url":"https://api.github.com/repos/d-beloved/Ride-my-way/languages","stargazers_url":"https://api.github.com/repos/d-beloved/Ride-my-way/stargazers","contributors_url":"https://api.github.com/repos/d-beloved/Ride-my-way/contributors","subscribers_url":"https://api.github.com/repos/d-beloved/Ride-my-way/subscribers","subscription_url":"https://api.github.com/repos/d-beloved/Ride-my-way/subscription","commits_url":"https://api.github.com/repos/d-beloved/Ride-my-way/commits{/sha}","git_commits_url":"https://api.github.com/repos/d-beloved/Ride-my-way/git/commits{/sha}","comments_url":"https://api.github.com/repos/d-beloved/Ride-my-way/comments{/number}","issue_comment_url":"https://api.github.com/repos/d-beloved/Ride-my-way/issues/comments{/number}","contents_url":"https://api.github.com/repos/d-beloved/Ride-my-way/contents/{+path}","compare_url":"https://api.github.com/repos/d-beloved/Ride-my-way/compare/{base}...{head}","merges_url":"https://api.github.com/repos/d-beloved/Ride-my-way/merges","archive_url":"https://api.github.com/repos/d-beloved/Ride-my-way/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/d-beloved/Ride-my-way/downloads","issues_url":"https://api.github.com/repos/d-beloved/Ride-my-way/issues{/number}","pulls_url":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls{/number}","milestones_url":"https://api.github.com/repos/d-beloved/Ride-my-way/milestones{/number}","notifications_url":"https://api.github.com/repos/d-beloved/Ride-my-way/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/d-beloved/Ride-my-way/labels{/name}","releases_url":"https://api.github.com/repos/d-beloved/Ride-my-way/releases{/id}","deployments_url":"https://api.github.com/repos/d-beloved/Ride-my-way/deployments","created_at":"2018-06-11T23:40:37Z","updated_at":"2018-07-03T10:00:08Z","pushed_at":"2018-07-03T15:09:39Z","git_url":"git://github.com/d-beloved/Ride-my-way.git","ssh_url":"git@github.com:d-beloved/Ride-my-way.git","clone_url":"https://github.com/d-beloved/Ride-my-way.git","svn_url":"https://github.com/d-beloved/Ride-my-way","homepage":null,"size":704,"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":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"base":{"label":"d-beloved:develop","ref":"develop","sha":"5825f72ab14472108146f247304fb6d14a6099db","user":{"login":"d-beloved","id":26516851,"node_id":"MDQ6VXNlcjI2NTE2ODUx","avatar_url":"https://avatars0.githubusercontent.com/u/26516851?v=4","gravatar_id":"","url":"https://api.github.com/users/d-beloved","html_url":"https://github.com/d-beloved","followers_url":"https://api.github.com/users/d-beloved/followers","following_url":"https://api.github.com/users/d-beloved/following{/other_user}","gists_url":"https://api.github.com/users/d-beloved/gists{/gist_id}","starred_url":"https://api.github.com/users/d-beloved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d-beloved/subscriptions","organizations_url":"https://api.github.com/users/d-beloved/orgs","repos_url":"https://api.github.com/users/d-beloved/repos","events_url":"https://api.github.com/users/d-beloved/events{/privacy}","received_events_url":"https://api.github.com/users/d-beloved/received_events","type":"User","site_admin":false},"repo":{"id":136992653,"node_id":"MDEwOlJlcG9zaXRvcnkxMzY5OTI2NTM=","name":"Ride-my-way","full_name":"d-beloved/Ride-my-way","owner":{"login":"d-beloved","id":26516851,"node_id":"MDQ6VXNlcjI2NTE2ODUx","avatar_url":"https://avatars0.githubusercontent.com/u/26516851?v=4","gravatar_id":"","url":"https://api.github.com/users/d-beloved","html_url":"https://github.com/d-beloved","followers_url":"https://api.github.com/users/d-beloved/followers","following_url":"https://api.github.com/users/d-beloved/following{/other_user}","gists_url":"https://api.github.com/users/d-beloved/gists{/gist_id}","starred_url":"https://api.github.com/users/d-beloved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d-beloved/subscriptions","organizations_url":"https://api.github.com/users/d-beloved/orgs","repos_url":"https://api.github.com/users/d-beloved/repos","events_url":"https://api.github.com/users/d-beloved/events{/privacy}","received_events_url":"https://api.github.com/users/d-beloved/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/d-beloved/Ride-my-way","description":"A carpooling application that provides drivers with the ability to create ride offers and passengers to join available ride offers","fork":false,"url":"https://api.github.com/repos/d-beloved/Ride-my-way","forks_url":"https://api.github.com/repos/d-beloved/Ride-my-way/forks","keys_url":"https://api.github.com/repos/d-beloved/Ride-my-way/keys{/key_id}","collaborators_url":"https://api.github.com/repos/d-beloved/Ride-my-way/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/d-beloved/Ride-my-way/teams","hooks_url":"https://api.github.com/repos/d-beloved/Ride-my-way/hooks","issue_events_url":"https://api.github.com/repos/d-beloved/Ride-my-way/issues/events{/number}","events_url":"https://api.github.com/repos/d-beloved/Ride-my-way/events","assignees_url":"https://api.github.com/repos/d-beloved/Ride-my-way/assignees{/user}","branches_url":"https://api.github.com/repos/d-beloved/Ride-my-way/branches{/branch}","tags_url":"https://api.github.com/repos/d-beloved/Ride-my-way/tags","blobs_url":"https://api.github.com/repos/d-beloved/Ride-my-way/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/d-beloved/Ride-my-way/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/d-beloved/Ride-my-way/git/refs{/sha}","trees_url":"https://api.github.com/repos/d-beloved/Ride-my-way/git/trees{/sha}","statuses_url":"https://api.github.com/repos/d-beloved/Ride-my-way/statuses/{sha}","languages_url":"https://api.github.com/repos/d-beloved/Ride-my-way/languages","stargazers_url":"https://api.github.com/repos/d-beloved/Ride-my-way/stargazers","contributors_url":"https://api.github.com/repos/d-beloved/Ride-my-way/contributors","subscribers_url":"https://api.github.com/repos/d-beloved/Ride-my-way/subscribers","subscription_url":"https://api.github.com/repos/d-beloved/Ride-my-way/subscription","commits_url":"https://api.github.com/repos/d-beloved/Ride-my-way/commits{/sha}","git_commits_url":"https://api.github.com/repos/d-beloved/Ride-my-way/git/commits{/sha}","comments_url":"https://api.github.com/repos/d-beloved/Ride-my-way/comments{/number}","issue_comment_url":"https://api.github.com/repos/d-beloved/Ride-my-way/issues/comments{/number}","contents_url":"https://api.github.com/repos/d-beloved/Ride-my-way/contents/{+path}","compare_url":"https://api.github.com/repos/d-beloved/Ride-my-way/compare/{base}...{head}","merges_url":"https://api.github.com/repos/d-beloved/Ride-my-way/merges","archive_url":"https://api.github.com/repos/d-beloved/Ride-my-way/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/d-beloved/Ride-my-way/downloads","issues_url":"https://api.github.com/repos/d-beloved/Ride-my-way/issues{/number}","pulls_url":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls{/number}","milestones_url":"https://api.github.com/repos/d-beloved/Ride-my-way/milestones{/number}","notifications_url":"https://api.github.com/repos/d-beloved/Ride-my-way/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/d-beloved/Ride-my-way/labels{/name}","releases_url":"https://api.github.com/repos/d-beloved/Ride-my-way/releases{/id}","deployments_url":"https://api.github.com/repos/d-beloved/Ride-my-way/deployments","created_at":"2018-06-11T23:40:37Z","updated_at":"2018-07-03T10:00:08Z","pushed_at":"2018-07-03T15:09:39Z","git_url":"git://github.com/d-beloved/Ride-my-way.git","ssh_url":"git@github.com:d-beloved/Ride-my-way.git","clone_url":"https://github.com/d-beloved/Ride-my-way.git","svn_url":"https://github.com/d-beloved/Ride-my-way","homepage":null,"size":704,"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":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/11"},"html":{"href":"https://github.com/d-beloved/Ride-my-way/pull/11"},"issue":{"href":"https://api.github.com/repos/d-beloved/Ride-my-way/issues/11"},"comments":{"href":"https://api.github.com/repos/d-beloved/Ride-my-way/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/d-beloved/Ride-my-way/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/d-beloved/Ride-my-way/statuses/09396f265a703507a6b3a114e5b7af455cfcbf53"}},"author_association":"OWNER"}}
{"actor":{"display_login":"andela-gesit"}}