{"action":"created","comment":{"url":"https://api.github.com/repos/kogai/kindlized/pulls/comments/41812093","id":41812093,"diff_hunk":"@@ -5,83 +5,83 @@ const User = require('common/User')\n const Book = require('common/Book')()\n \n module.exports = {\n-\tget: function(req, res){\n-\t\tif(!req.session.passport.user){\n-\t\t\treturn res.status(500).send()\n-\t\t}\n-\t\tlet user = User(req.session.passport.user)\n-\t\tlet page = Number(req.query.page)\n+  get: function(req, res){\n+    if(!req.session.passport.user){\n+      return res.status(500).send()\n+    }\n+    let user = User(req.session.passport.user)\n+    let page = Number(req.query.page)\n \n-\t\tuser.fetchRegisteredBooks(function(err, bookList){\n-\t\t\tif(err){\n-\t\t\t\treturn log.info(err)\n-\t\t\t}\n+    user.fetchRegisteredBooks(function(err, bookList){\n+      if(err){\n+        return log.info(err)\n+      }\n \n-\t\t\tlet conditions = {\n-\t\t\t\t_id: { $in: bookList.map(function(book){ return book.bookId }) }\n-\t\t\t}\n-\t\t\tif(page){\n-\t\t\t\t// クエリパラメータにpageの指定があればそのページを返す\n-\t\t\t\tBook.fetchPage(conditions, page, function(err, books, hasNext){\n-\t\t\t\t\tif(err){\n-\t\t\t\t\t\treturn log.info(err)\n-\t\t\t\t\t}\n-\t\t\t\t\tres.send({\n-\t\t\t\t\t\tmaxCount: bookList.length,\n-\t\t\t\t\t\tbooks: books.map(function(book){\n-\t\t\t\t\t\t\treturn Book.sanitizeForClient(book)\n-\t\t\t\t\t\t}),\n-\t\t\t\t\t\thasNext: hasNext\n-\t\t\t\t\t})\n-\t\t\t\t})\n-\t\t\t}else{\n-\t\t\t\t// クエリパラメータがなければ全件を返す\n-\t\t\t\tBook.fetchAll(conditions, function(err, books){\n-\t\t\t\t\tif(err){\n-\t\t\t\t\t\treturn log.info(err)\n-\t\t\t\t\t}\n-\t\t\t\t\tres.send({\n-\t\t\t\t\t\tmaxCount: bookList.length,\n-\t\t\t\t\t\tbooks: books.map(function(book){\n-\t\t\t\t\t\t\treturn Book.sanitizeForClient(book)\n-\t\t\t\t\t\t})\n-\t\t\t\t\t})\n-\t\t\t\t})\n-\t\t\t}\n-\t\t})\n-\t},\n+      let conditions = {\n+        _id: { $in: bookList.map(function(book){ return book.bookId }) }\n+      }\n+      if(page){\n+        // クエリパラメータにpageの指定があればそのページを返す\n+        Book.fetchPage(conditions, page, function(err, books, hasNext){\n+          if(err){\n+            return log.info(err)\n+          }\n+          res.send({\n+            maxCount: bookList.length,\n+            books: books.map(function(book){\n+              return Book.sanitizeForClient(book)\n+            }),\n+            hasNext: hasNext\n+          })\n+        })\n+      }else{\n+        // クエリパラメータがなければ全件を返す\n+        Book.fetchAll(conditions, function(err, books){\n+          if(err){\n+            return log.info(err)\n+          }\n+          res.send({\n+            maxCount: bookList.length,\n+            books: books.map(function(book){\n+              return Book.sanitizeForClient(book)\n+            })\n+          })\n+        })\n+      }\n+    })\n+  },\n \n-\tpost: function(req, res){\n-\t\tif(!req.session.passport.user){\n-\t\t\treturn res.status(500).send()\n-\t\t}\n-\t\tlet user = User(req.session.passport.user)\n-\t\tlet book = req.body.newBook\n+  post: function(req, res){\n+    if(!req.session.passport.user){\n+      return res.status(500).send()\n+    }\n+    let user = User(req.session.passport.user)\n+    let book = req.body.newBook\n \n-\t\tuser.saveBook(book, function(err, savedUser){\n-\t\t\tif(err){\n-\t\t\t\treturn log.info(err)\n-\t\t\t}\n-\t\t\tif(typeof savedUser === 'string'){\n-\t\t\t\treturn log.info(savedUser)\n-\t\t\t}\n-\t\t\tres.send({\n-\t\t\t\tnewBook: book\n-\t\t\t})\n-\t\t})\n-\t},\n+    user.saveBook(book, function(err, savedUser){\n+      if(err){\n+        return log.info(err)\n+      }\n+      if(typeof savedUser === 'string'){\n+        return log.info(savedUser)\n+      }\n+      res.send({\n+        newBook: book\n+      })","path":"routes/api/user/book.js","position":127,"original_position":127,"commit_id":"47e1ed5e71f2a080d689e13e815c2bd044c10b61","original_commit_id":"47e1ed5e71f2a080d689e13e815c2bd044c10b61","user":{"login":"kogai","id":4057326,"avatar_url":"https://avatars.githubusercontent.com/u/4057326?v=3","gravatar_id":"","url":"https://api.github.com/users/kogai","html_url":"https://github.com/kogai","followers_url":"https://api.github.com/users/kogai/followers","following_url":"https://api.github.com/users/kogai/following{/other_user}","gists_url":"https://api.github.com/users/kogai/gists{/gist_id}","starred_url":"https://api.github.com/users/kogai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kogai/subscriptions","organizations_url":"https://api.github.com/users/kogai/orgs","repos_url":"https://api.github.com/users/kogai/repos","events_url":"https://api.github.com/users/kogai/events{/privacy}","received_events_url":"https://api.github.com/users/kogai/received_events","type":"User","site_admin":false},"body":"__[jshint]__\n*  Missing semicolon.\n","created_at":"2015-10-12T23:25:28Z","updated_at":"2015-10-12T23:25:28Z","html_url":"https://github.com/kogai/kindlized/pull/50#discussion_r41812093","pull_request_url":"https://api.github.com/repos/kogai/kindlized/pulls/50","_links":{"self":{"href":"https://api.github.com/repos/kogai/kindlized/pulls/comments/41812093"},"html":{"href":"https://github.com/kogai/kindlized/pull/50#discussion_r41812093"},"pull_request":{"href":"https://api.github.com/repos/kogai/kindlized/pulls/50"}}},"pull_request":{"url":"https://api.github.com/repos/kogai/kindlized/pulls/50","id":47475390,"html_url":"https://github.com/kogai/kindlized/pull/50","diff_url":"https://github.com/kogai/kindlized/pull/50.diff","patch_url":"https://github.com/kogai/kindlized/pull/50.patch","issue_url":"https://api.github.com/repos/kogai/kindlized/issues/50","number":50,"state":"closed","locked":false,"title":"テストの整理","user":{"login":"kogai","id":4057326,"avatar_url":"https://avatars.githubusercontent.com/u/4057326?v=3","gravatar_id":"","url":"https://api.github.com/users/kogai","html_url":"https://github.com/kogai","followers_url":"https://api.github.com/users/kogai/followers","following_url":"https://api.github.com/users/kogai/following{/other_user}","gists_url":"https://api.github.com/users/kogai/gists{/gist_id}","starred_url":"https://api.github.com/users/kogai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kogai/subscriptions","organizations_url":"https://api.github.com/users/kogai/orgs","repos_url":"https://api.github.com/users/kogai/repos","events_url":"https://api.github.com/users/kogai/events{/privacy}","received_events_url":"https://api.github.com/users/kogai/received_events","type":"User","site_admin":false},"body":"close #46 ","created_at":"2015-10-12T23:24:13Z","updated_at":"2015-10-12T23:25:28Z","closed_at":"2015-10-12T23:24:18Z","merged_at":"2015-10-12T23:24:18Z","merge_commit_sha":"05445e728f15b17782c217fe262e389e7ccbc5b1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kogai/kindlized/pulls/50/commits","review_comments_url":"https://api.github.com/repos/kogai/kindlized/pulls/50/comments","review_comment_url":"https://api.github.com/repos/kogai/kindlized/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kogai/kindlized/issues/50/comments","statuses_url":"https://api.github.com/repos/kogai/kindlized/statuses/47e1ed5e71f2a080d689e13e815c2bd044c10b61","head":{"label":"kogai:t46","ref":"t46","sha":"47e1ed5e71f2a080d689e13e815c2bd044c10b61","user":{"login":"kogai","id":4057326,"avatar_url":"https://avatars.githubusercontent.com/u/4057326?v=3","gravatar_id":"","url":"https://api.github.com/users/kogai","html_url":"https://github.com/kogai","followers_url":"https://api.github.com/users/kogai/followers","following_url":"https://api.github.com/users/kogai/following{/other_user}","gists_url":"https://api.github.com/users/kogai/gists{/gist_id}","starred_url":"https://api.github.com/users/kogai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kogai/subscriptions","organizations_url":"https://api.github.com/users/kogai/orgs","repos_url":"https://api.github.com/users/kogai/repos","events_url":"https://api.github.com/users/kogai/events{/privacy}","received_events_url":"https://api.github.com/users/kogai/received_events","type":"User","site_admin":false},"repo":{"id":27324315,"name":"kindlized","full_name":"kogai/kindlized","owner":{"login":"kogai","id":4057326,"avatar_url":"https://avatars.githubusercontent.com/u/4057326?v=3","gravatar_id":"","url":"https://api.github.com/users/kogai","html_url":"https://github.com/kogai","followers_url":"https://api.github.com/users/kogai/followers","following_url":"https://api.github.com/users/kogai/following{/other_user}","gists_url":"https://api.github.com/users/kogai/gists{/gist_id}","starred_url":"https://api.github.com/users/kogai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kogai/subscriptions","organizations_url":"https://api.github.com/users/kogai/orgs","repos_url":"https://api.github.com/users/kogai/repos","events_url":"https://api.github.com/users/kogai/events{/privacy}","received_events_url":"https://api.github.com/users/kogai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kogai/kindlized","description":"","fork":false,"url":"https://api.github.com/repos/kogai/kindlized","forks_url":"https://api.github.com/repos/kogai/kindlized/forks","keys_url":"https://api.github.com/repos/kogai/kindlized/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kogai/kindlized/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kogai/kindlized/teams","hooks_url":"https://api.github.com/repos/kogai/kindlized/hooks","issue_events_url":"https://api.github.com/repos/kogai/kindlized/issues/events{/number}","events_url":"https://api.github.com/repos/kogai/kindlized/events","assignees_url":"https://api.github.com/repos/kogai/kindlized/assignees{/user}","branches_url":"https://api.github.com/repos/kogai/kindlized/branches{/branch}","tags_url":"https://api.github.com/repos/kogai/kindlized/tags","blobs_url":"https://api.github.com/repos/kogai/kindlized/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kogai/kindlized/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kogai/kindlized/git/refs{/sha}","trees_url":"https://api.github.com/repos/kogai/kindlized/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kogai/kindlized/statuses/{sha}","languages_url":"https://api.github.com/repos/kogai/kindlized/languages","stargazers_url":"https://api.github.com/repos/kogai/kindlized/stargazers","contributors_url":"https://api.github.com/repos/kogai/kindlized/contributors","subscribers_url":"https://api.github.com/repos/kogai/kindlized/subscribers","subscription_url":"https://api.github.com/repos/kogai/kindlized/subscription","commits_url":"https://api.github.com/repos/kogai/kindlized/commits{/sha}","git_commits_url":"https://api.github.com/repos/kogai/kindlized/git/commits{/sha}","comments_url":"https://api.github.com/repos/kogai/kindlized/comments{/number}","issue_comment_url":"https://api.github.com/repos/kogai/kindlized/issues/comments{/number}","contents_url":"https://api.github.com/repos/kogai/kindlized/contents/{+path}","compare_url":"https://api.github.com/repos/kogai/kindlized/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kogai/kindlized/merges","archive_url":"https://api.github.com/repos/kogai/kindlized/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kogai/kindlized/downloads","issues_url":"https://api.github.com/repos/kogai/kindlized/issues{/number}","pulls_url":"https://api.github.com/repos/kogai/kindlized/pulls{/number}","milestones_url":"https://api.github.com/repos/kogai/kindlized/milestones{/number}","notifications_url":"https://api.github.com/repos/kogai/kindlized/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kogai/kindlized/labels{/name}","releases_url":"https://api.github.com/repos/kogai/kindlized/releases{/id}","created_at":"2014-11-30T04:24:43Z","updated_at":"2015-05-08T02:17:07Z","pushed_at":"2015-10-12T23:24:18Z","git_url":"git://github.com/kogai/kindlized.git","ssh_url":"git@github.com:kogai/kindlized.git","clone_url":"https://github.com/kogai/kindlized.git","svn_url":"https://github.com/kogai/kindlized","homepage":"http://kindlize.it/","size":4280,"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":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"kogai:master","ref":"master","sha":"8761cef12f0e9c6b2dfb5de348b26c85d033dc2c","user":{"login":"kogai","id":4057326,"avatar_url":"https://avatars.githubusercontent.com/u/4057326?v=3","gravatar_id":"","url":"https://api.github.com/users/kogai","html_url":"https://github.com/kogai","followers_url":"https://api.github.com/users/kogai/followers","following_url":"https://api.github.com/users/kogai/following{/other_user}","gists_url":"https://api.github.com/users/kogai/gists{/gist_id}","starred_url":"https://api.github.com/users/kogai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kogai/subscriptions","organizations_url":"https://api.github.com/users/kogai/orgs","repos_url":"https://api.github.com/users/kogai/repos","events_url":"https://api.github.com/users/kogai/events{/privacy}","received_events_url":"https://api.github.com/users/kogai/received_events","type":"User","site_admin":false},"repo":{"id":27324315,"name":"kindlized","full_name":"kogai/kindlized","owner":{"login":"kogai","id":4057326,"avatar_url":"https://avatars.githubusercontent.com/u/4057326?v=3","gravatar_id":"","url":"https://api.github.com/users/kogai","html_url":"https://github.com/kogai","followers_url":"https://api.github.com/users/kogai/followers","following_url":"https://api.github.com/users/kogai/following{/other_user}","gists_url":"https://api.github.com/users/kogai/gists{/gist_id}","starred_url":"https://api.github.com/users/kogai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kogai/subscriptions","organizations_url":"https://api.github.com/users/kogai/orgs","repos_url":"https://api.github.com/users/kogai/repos","events_url":"https://api.github.com/users/kogai/events{/privacy}","received_events_url":"https://api.github.com/users/kogai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kogai/kindlized","description":"","fork":false,"url":"https://api.github.com/repos/kogai/kindlized","forks_url":"https://api.github.com/repos/kogai/kindlized/forks","keys_url":"https://api.github.com/repos/kogai/kindlized/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kogai/kindlized/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kogai/kindlized/teams","hooks_url":"https://api.github.com/repos/kogai/kindlized/hooks","issue_events_url":"https://api.github.com/repos/kogai/kindlized/issues/events{/number}","events_url":"https://api.github.com/repos/kogai/kindlized/events","assignees_url":"https://api.github.com/repos/kogai/kindlized/assignees{/user}","branches_url":"https://api.github.com/repos/kogai/kindlized/branches{/branch}","tags_url":"https://api.github.com/repos/kogai/kindlized/tags","blobs_url":"https://api.github.com/repos/kogai/kindlized/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kogai/kindlized/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kogai/kindlized/git/refs{/sha}","trees_url":"https://api.github.com/repos/kogai/kindlized/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kogai/kindlized/statuses/{sha}","languages_url":"https://api.github.com/repos/kogai/kindlized/languages","stargazers_url":"https://api.github.com/repos/kogai/kindlized/stargazers","contributors_url":"https://api.github.com/repos/kogai/kindlized/contributors","subscribers_url":"https://api.github.com/repos/kogai/kindlized/subscribers","subscription_url":"https://api.github.com/repos/kogai/kindlized/subscription","commits_url":"https://api.github.com/repos/kogai/kindlized/commits{/sha}","git_commits_url":"https://api.github.com/repos/kogai/kindlized/git/commits{/sha}","comments_url":"https://api.github.com/repos/kogai/kindlized/comments{/number}","issue_comment_url":"https://api.github.com/repos/kogai/kindlized/issues/comments{/number}","contents_url":"https://api.github.com/repos/kogai/kindlized/contents/{+path}","compare_url":"https://api.github.com/repos/kogai/kindlized/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kogai/kindlized/merges","archive_url":"https://api.github.com/repos/kogai/kindlized/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kogai/kindlized/downloads","issues_url":"https://api.github.com/repos/kogai/kindlized/issues{/number}","pulls_url":"https://api.github.com/repos/kogai/kindlized/pulls{/number}","milestones_url":"https://api.github.com/repos/kogai/kindlized/milestones{/number}","notifications_url":"https://api.github.com/repos/kogai/kindlized/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kogai/kindlized/labels{/name}","releases_url":"https://api.github.com/repos/kogai/kindlized/releases{/id}","created_at":"2014-11-30T04:24:43Z","updated_at":"2015-05-08T02:17:07Z","pushed_at":"2015-10-12T23:24:18Z","git_url":"git://github.com/kogai/kindlized.git","ssh_url":"git@github.com:kogai/kindlized.git","clone_url":"https://github.com/kogai/kindlized.git","svn_url":"https://github.com/kogai/kindlized","homepage":"http://kindlize.it/","size":4280,"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":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kogai/kindlized/pulls/50"},"html":{"href":"https://github.com/kogai/kindlized/pull/50"},"issue":{"href":"https://api.github.com/repos/kogai/kindlized/issues/50"},"comments":{"href":"https://api.github.com/repos/kogai/kindlized/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/kogai/kindlized/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/kogai/kindlized/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kogai/kindlized/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/kogai/kindlized/statuses/47e1ed5e71f2a080d689e13e815c2bd044c10b61"}}}}