{"action":"created","comment":{"url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/comments/38832572","id":38832572,"diff_hunk":"@@ -0,0 +1,128 @@\n+//---------------------------------\n+//DEPENDENCIES\n+//---------------------------------\n+\n+var Error400    = require('../../lib/errors/error400');\n+var ApiErrors   = require('../../lib/apiError');\n+var _           = require('underscore');\n+var Distributor = require('../models/distributor');\n+\n+exports.getDistributor = function(req, res, next) {\n+\tvar id = req.params.id;\n+\tvar offset = req.query.offset;\n+\tvar limit = req.query.limit;\n+\tvar criteria = {};\n+\n+\tif (req.query.q) {\n+\t\tvar expr = new RegExp('.*' + req.query.q + '.*');\n+\t\tcriteria.$or = [\n+\t\t\t{ name : expr },\n+\t\t  { information : expr },\n+\t\t\t{ email : expr },\n+\t\t\t{ phone : expr }\n+\t\t]\n+\t}\n+\n+\tif (req.query.name) {\n+\t\tcriteria.name = req.query.name;\n+\t}\n+\n+\tif (req.query.information) {\n+\t\tcriteria.information = req.query.information;\n+\t}\n+\n+\tif (req.query.phone) {\n+\t\tcriteria.information = req.query.phone;\n+\t}\n+\n+\tif (req.query.email) {\n+\t\tcriteria.email = req.query.email;\n+\t}\n+\n+\tDistributor.find(criteria)\n+\t\t.skip(offset)\n+\t\t.limit(limit)\n+\t\t.populate('shops','name address')\n+\t\t.exec( function(err, dtbutors){\n+\t\t\tif (err) return next(err);\n+\t\t\tDistributor.count(criteria, function(err, count){\n+\t\t\t\tif (err) return next(err);\n+\t\t\t\tvar record = {};\n+\t\t\t\trecord.total = count;\n+\t\t\t\tif (limit && (limit != 0)) {\n+\t\t\t\t\trecord.offset = offset;\n+\t\t\t\t\trecord.limit = limit;\n+\t\t\t\t\trecord.currentPages = Math.ceil(offset/limit);\n+\t\t\t\t\trecord.totalPages = Math.ceil(count/limit);\n+\t\t\t\t}\n+\t\t\t\trecord.receivedRecords = dtbutors.length;\n+\t\t\t\tres.json({ distributors: dtbutors, record : record });\n+\t\t\t});\n+\t\t});\n+}\n+\n+exports.postDistributor = function(req, res, next) {\n+\tconsole.log(\"post\");","path":"app/controllers/distributor.js","position":65,"original_position":65,"commit_id":"25c6aaa61d56fe04eb8c494d67975be693006cc6","original_commit_id":"25c6aaa61d56fe04eb8c494d67975be693006cc6","user":{"login":"hdvgamestudio","id":10759193,"avatar_url":"https://avatars.githubusercontent.com/u/10759193?v=3","gravatar_id":"","url":"https://api.github.com/users/hdvgamestudio","html_url":"https://github.com/hdvgamestudio","followers_url":"https://api.github.com/users/hdvgamestudio/followers","following_url":"https://api.github.com/users/hdvgamestudio/following{/other_user}","gists_url":"https://api.github.com/users/hdvgamestudio/gists{/gist_id}","starred_url":"https://api.github.com/users/hdvgamestudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hdvgamestudio/subscriptions","organizations_url":"https://api.github.com/users/hdvgamestudio/orgs","repos_url":"https://api.github.com/users/hdvgamestudio/repos","events_url":"https://api.github.com/users/hdvgamestudio/events{/privacy}","received_events_url":"https://api.github.com/users/hdvgamestudio/received_events","type":"User","site_admin":false},"body":"* Xóa dòng này đi","created_at":"2015-09-07T04:11:31Z","updated_at":"2015-09-07T04:11:31Z","html_url":"https://github.com/hdvgamestudio/beauty-APIs/pull/9#discussion_r38832572","pull_request_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/comments/38832572"},"html":{"href":"https://github.com/hdvgamestudio/beauty-APIs/pull/9#discussion_r38832572"},"pull_request":{"href":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/9","id":44318258,"html_url":"https://github.com/hdvgamestudio/beauty-APIs/pull/9","diff_url":"https://github.com/hdvgamestudio/beauty-APIs/pull/9.diff","patch_url":"https://github.com/hdvgamestudio/beauty-APIs/pull/9.patch","issue_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/issues/9","number":9,"state":"open","locked":false,"title":"add distributor and fix shop","user":{"login":"lntitbk","id":2908347,"avatar_url":"https://avatars.githubusercontent.com/u/2908347?v=3","gravatar_id":"","url":"https://api.github.com/users/lntitbk","html_url":"https://github.com/lntitbk","followers_url":"https://api.github.com/users/lntitbk/followers","following_url":"https://api.github.com/users/lntitbk/following{/other_user}","gists_url":"https://api.github.com/users/lntitbk/gists{/gist_id}","starred_url":"https://api.github.com/users/lntitbk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lntitbk/subscriptions","organizations_url":"https://api.github.com/users/lntitbk/orgs","repos_url":"https://api.github.com/users/lntitbk/repos","events_url":"https://api.github.com/users/lntitbk/events{/privacy}","received_events_url":"https://api.github.com/users/lntitbk/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-07T03:54:05Z","updated_at":"2015-09-07T04:11:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/9/commits","review_comments_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/9/comments","review_comment_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/issues/9/comments","statuses_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/statuses/25c6aaa61d56fe04eb8c494d67975be693006cc6","head":{"label":"lntitbk:develop","ref":"develop","sha":"25c6aaa61d56fe04eb8c494d67975be693006cc6","user":{"login":"lntitbk","id":2908347,"avatar_url":"https://avatars.githubusercontent.com/u/2908347?v=3","gravatar_id":"","url":"https://api.github.com/users/lntitbk","html_url":"https://github.com/lntitbk","followers_url":"https://api.github.com/users/lntitbk/followers","following_url":"https://api.github.com/users/lntitbk/following{/other_user}","gists_url":"https://api.github.com/users/lntitbk/gists{/gist_id}","starred_url":"https://api.github.com/users/lntitbk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lntitbk/subscriptions","organizations_url":"https://api.github.com/users/lntitbk/orgs","repos_url":"https://api.github.com/users/lntitbk/repos","events_url":"https://api.github.com/users/lntitbk/events{/privacy}","received_events_url":"https://api.github.com/users/lntitbk/received_events","type":"User","site_admin":false},"repo":{"id":41462193,"name":"beauty-APIs","full_name":"lntitbk/beauty-APIs","owner":{"login":"lntitbk","id":2908347,"avatar_url":"https://avatars.githubusercontent.com/u/2908347?v=3","gravatar_id":"","url":"https://api.github.com/users/lntitbk","html_url":"https://github.com/lntitbk","followers_url":"https://api.github.com/users/lntitbk/followers","following_url":"https://api.github.com/users/lntitbk/following{/other_user}","gists_url":"https://api.github.com/users/lntitbk/gists{/gist_id}","starred_url":"https://api.github.com/users/lntitbk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lntitbk/subscriptions","organizations_url":"https://api.github.com/users/lntitbk/orgs","repos_url":"https://api.github.com/users/lntitbk/repos","events_url":"https://api.github.com/users/lntitbk/events{/privacy}","received_events_url":"https://api.github.com/users/lntitbk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lntitbk/beauty-APIs","description":"","fork":true,"url":"https://api.github.com/repos/lntitbk/beauty-APIs","forks_url":"https://api.github.com/repos/lntitbk/beauty-APIs/forks","keys_url":"https://api.github.com/repos/lntitbk/beauty-APIs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lntitbk/beauty-APIs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lntitbk/beauty-APIs/teams","hooks_url":"https://api.github.com/repos/lntitbk/beauty-APIs/hooks","issue_events_url":"https://api.github.com/repos/lntitbk/beauty-APIs/issues/events{/number}","events_url":"https://api.github.com/repos/lntitbk/beauty-APIs/events","assignees_url":"https://api.github.com/repos/lntitbk/beauty-APIs/assignees{/user}","branches_url":"https://api.github.com/repos/lntitbk/beauty-APIs/branches{/branch}","tags_url":"https://api.github.com/repos/lntitbk/beauty-APIs/tags","blobs_url":"https://api.github.com/repos/lntitbk/beauty-APIs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lntitbk/beauty-APIs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lntitbk/beauty-APIs/git/refs{/sha}","trees_url":"https://api.github.com/repos/lntitbk/beauty-APIs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lntitbk/beauty-APIs/statuses/{sha}","languages_url":"https://api.github.com/repos/lntitbk/beauty-APIs/languages","stargazers_url":"https://api.github.com/repos/lntitbk/beauty-APIs/stargazers","contributors_url":"https://api.github.com/repos/lntitbk/beauty-APIs/contributors","subscribers_url":"https://api.github.com/repos/lntitbk/beauty-APIs/subscribers","subscription_url":"https://api.github.com/repos/lntitbk/beauty-APIs/subscription","commits_url":"https://api.github.com/repos/lntitbk/beauty-APIs/commits{/sha}","git_commits_url":"https://api.github.com/repos/lntitbk/beauty-APIs/git/commits{/sha}","comments_url":"https://api.github.com/repos/lntitbk/beauty-APIs/comments{/number}","issue_comment_url":"https://api.github.com/repos/lntitbk/beauty-APIs/issues/comments{/number}","contents_url":"https://api.github.com/repos/lntitbk/beauty-APIs/contents/{+path}","compare_url":"https://api.github.com/repos/lntitbk/beauty-APIs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lntitbk/beauty-APIs/merges","archive_url":"https://api.github.com/repos/lntitbk/beauty-APIs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lntitbk/beauty-APIs/downloads","issues_url":"https://api.github.com/repos/lntitbk/beauty-APIs/issues{/number}","pulls_url":"https://api.github.com/repos/lntitbk/beauty-APIs/pulls{/number}","milestones_url":"https://api.github.com/repos/lntitbk/beauty-APIs/milestones{/number}","notifications_url":"https://api.github.com/repos/lntitbk/beauty-APIs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lntitbk/beauty-APIs/labels{/name}","releases_url":"https://api.github.com/repos/lntitbk/beauty-APIs/releases{/id}","created_at":"2015-08-27T02:51:56Z","updated_at":"2015-08-27T02:51:56Z","pushed_at":"2015-09-07T03:43:15Z","git_url":"git://github.com/lntitbk/beauty-APIs.git","ssh_url":"git@github.com:lntitbk/beauty-APIs.git","clone_url":"https://github.com/lntitbk/beauty-APIs.git","svn_url":"https://github.com/lntitbk/beauty-APIs","homepage":null,"size":150,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hdvgamestudio:develop","ref":"develop","sha":"e922abae95fdda12b775e5280df040c7af5b3cdb","user":{"login":"hdvgamestudio","id":10759193,"avatar_url":"https://avatars.githubusercontent.com/u/10759193?v=3","gravatar_id":"","url":"https://api.github.com/users/hdvgamestudio","html_url":"https://github.com/hdvgamestudio","followers_url":"https://api.github.com/users/hdvgamestudio/followers","following_url":"https://api.github.com/users/hdvgamestudio/following{/other_user}","gists_url":"https://api.github.com/users/hdvgamestudio/gists{/gist_id}","starred_url":"https://api.github.com/users/hdvgamestudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hdvgamestudio/subscriptions","organizations_url":"https://api.github.com/users/hdvgamestudio/orgs","repos_url":"https://api.github.com/users/hdvgamestudio/repos","events_url":"https://api.github.com/users/hdvgamestudio/events{/privacy}","received_events_url":"https://api.github.com/users/hdvgamestudio/received_events","type":"User","site_admin":false},"repo":{"id":40704022,"name":"beauty-APIs","full_name":"hdvgamestudio/beauty-APIs","owner":{"login":"hdvgamestudio","id":10759193,"avatar_url":"https://avatars.githubusercontent.com/u/10759193?v=3","gravatar_id":"","url":"https://api.github.com/users/hdvgamestudio","html_url":"https://github.com/hdvgamestudio","followers_url":"https://api.github.com/users/hdvgamestudio/followers","following_url":"https://api.github.com/users/hdvgamestudio/following{/other_user}","gists_url":"https://api.github.com/users/hdvgamestudio/gists{/gist_id}","starred_url":"https://api.github.com/users/hdvgamestudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hdvgamestudio/subscriptions","organizations_url":"https://api.github.com/users/hdvgamestudio/orgs","repos_url":"https://api.github.com/users/hdvgamestudio/repos","events_url":"https://api.github.com/users/hdvgamestudio/events{/privacy}","received_events_url":"https://api.github.com/users/hdvgamestudio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hdvgamestudio/beauty-APIs","description":"","fork":false,"url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs","forks_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/forks","keys_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/teams","hooks_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/hooks","issue_events_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/issues/events{/number}","events_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/events","assignees_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/assignees{/user}","branches_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/branches{/branch}","tags_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/tags","blobs_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/git/refs{/sha}","trees_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/statuses/{sha}","languages_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/languages","stargazers_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/stargazers","contributors_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/contributors","subscribers_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/subscribers","subscription_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/subscription","commits_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/commits{/sha}","git_commits_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/git/commits{/sha}","comments_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/comments{/number}","issue_comment_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/issues/comments{/number}","contents_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/contents/{+path}","compare_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/merges","archive_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/downloads","issues_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/issues{/number}","pulls_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls{/number}","milestones_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/milestones{/number}","notifications_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/labels{/name}","releases_url":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/releases{/id}","created_at":"2015-08-14T08:23:19Z","updated_at":"2015-08-14T08:25:37Z","pushed_at":"2015-09-07T03:54:05Z","git_url":"git://github.com/hdvgamestudio/beauty-APIs.git","ssh_url":"git@github.com:hdvgamestudio/beauty-APIs.git","clone_url":"https://github.com/hdvgamestudio/beauty-APIs.git","svn_url":"https://github.com/hdvgamestudio/beauty-APIs","homepage":null,"size":295,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/9"},"html":{"href":"https://github.com/hdvgamestudio/beauty-APIs/pull/9"},"issue":{"href":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/issues/9"},"comments":{"href":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/hdvgamestudio/beauty-APIs/statuses/25c6aaa61d56fe04eb8c494d67975be693006cc6"}}}}