{"action":"created","comment":{"url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/comments/38611976","id":38611976,"diff_hunk":"@@ -0,0 +1,31 @@\n+var readline = require('readline');\n+var fs = require('fs');\n+var referrersFilePath = '.././docs/classifications.txt';\n+module.exports = function (event) {\n+\treturn new Promise((resolve, reject) => {\n+    var referrer = event.pluck('context.referrer') || event.headers().referer;\n+\t\tvar obj ={};\n+\t\tvar result = new Array();\n+\t\tfs.stat(referrersFilePath, function(err, stat) {\n+\t\t    if(err == null) {\n+\t\t\t\t\t\tvar rd = readline.createInterface({\n+\t\t\t\t\t\t\tinput: fs.createReadStream(referrersFilePath),\n+\t\t\t\t\t\t\toutput: process.stdout,\n+\t\t\t\t\t\t\tterminal: false\n+\t\t\t\t\t\t});\n+\t\t\t\t\trd.on('line', function(line) {\n+\t\t\t\t\t\tresult = line.split(',');\n+\t\t\t\t\t\tobj[result[0]] = (result[1]);\n+\t\t\t\t\t});\n+\t\t\t\t\trd.on('close', function() {\n+\t\t\t\t\t\tresolve ({\n+\t\t\t\t\t\t\treferrerType: (obj[referrer]) ? obj[referrer] : 'Direct'","path":"server/transforms/referrerType.js","position":22,"original_position":22,"commit_id":"741715a672bf59e272d164096b21de02ef95a93b","original_commit_id":"741715a672bf59e272d164096b21de02ef95a93b","user":{"login":"sarathjackendran","id":14014425,"avatar_url":"https://avatars.githubusercontent.com/u/14014425?v=3","gravatar_id":"","url":"https://api.github.com/users/sarathjackendran","html_url":"https://github.com/sarathjackendran","followers_url":"https://api.github.com/users/sarathjackendran/followers","following_url":"https://api.github.com/users/sarathjackendran/following{/other_user}","gists_url":"https://api.github.com/users/sarathjackendran/gists{/gist_id}","starred_url":"https://api.github.com/users/sarathjackendran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarathjackendran/subscriptions","organizations_url":"https://api.github.com/users/sarathjackendran/orgs","repos_url":"https://api.github.com/users/sarathjackendran/repos","events_url":"https://api.github.com/users/sarathjackendran/events{/privacy}","received_events_url":"https://api.github.com/users/sarathjackendran/received_events","type":"User","site_admin":false},"body":"Yes the reading of the file is expensive. Shall we have the content of the file in an array. Also I thought of ranking the match and sorting the array. So that the most frequently matched classification would be at the top of the array. Will this work as an optimisation?","created_at":"2015-09-03T04:17:42Z","updated_at":"2015-09-03T04:17:42Z","html_url":"https://github.com/Financial-Times/spoor-enrichment/pull/106#discussion_r38611976","pull_request_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/106","_links":{"self":{"href":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/comments/38611976"},"html":{"href":"https://github.com/Financial-Times/spoor-enrichment/pull/106#discussion_r38611976"},"pull_request":{"href":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/106"}}},"pull_request":{"url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/106","id":43617902,"html_url":"https://github.com/Financial-Times/spoor-enrichment/pull/106","diff_url":"https://github.com/Financial-Times/spoor-enrichment/pull/106.diff","patch_url":"https://github.com/Financial-Times/spoor-enrichment/pull/106.patch","issue_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/issues/106","number":106,"state":"open","locked":false,"title":"Implementing classification of referrer type","user":{"login":"sarathjackendran","id":14014425,"avatar_url":"https://avatars.githubusercontent.com/u/14014425?v=3","gravatar_id":"","url":"https://api.github.com/users/sarathjackendran","html_url":"https://github.com/sarathjackendran","followers_url":"https://api.github.com/users/sarathjackendran/followers","following_url":"https://api.github.com/users/sarathjackendran/following{/other_user}","gists_url":"https://api.github.com/users/sarathjackendran/gists{/gist_id}","starred_url":"https://api.github.com/users/sarathjackendran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarathjackendran/subscriptions","organizations_url":"https://api.github.com/users/sarathjackendran/orgs","repos_url":"https://api.github.com/users/sarathjackendran/repos","events_url":"https://api.github.com/users/sarathjackendran/events{/privacy}","received_events_url":"https://api.github.com/users/sarathjackendran/received_events","type":"User","site_admin":false},"body":"The url referrer classification has been added to the enrichment. Please review it.","created_at":"2015-08-28T11:20:46Z","updated_at":"2015-09-03T04:17:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d402a42046fdb15595c6e72b20fb1e2bf9a034ff","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/106/commits","review_comments_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/106/comments","review_comment_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/issues/106/comments","statuses_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/statuses/741715a672bf59e272d164096b21de02ef95a93b","head":{"label":"sarathjackendran:url_referer_enrichment","ref":"url_referer_enrichment","sha":"741715a672bf59e272d164096b21de02ef95a93b","user":{"login":"sarathjackendran","id":14014425,"avatar_url":"https://avatars.githubusercontent.com/u/14014425?v=3","gravatar_id":"","url":"https://api.github.com/users/sarathjackendran","html_url":"https://github.com/sarathjackendran","followers_url":"https://api.github.com/users/sarathjackendran/followers","following_url":"https://api.github.com/users/sarathjackendran/following{/other_user}","gists_url":"https://api.github.com/users/sarathjackendran/gists{/gist_id}","starred_url":"https://api.github.com/users/sarathjackendran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarathjackendran/subscriptions","organizations_url":"https://api.github.com/users/sarathjackendran/orgs","repos_url":"https://api.github.com/users/sarathjackendran/repos","events_url":"https://api.github.com/users/sarathjackendran/events{/privacy}","received_events_url":"https://api.github.com/users/sarathjackendran/received_events","type":"User","site_admin":false},"repo":{"id":41542179,"name":"spoor-enrichment","full_name":"sarathjackendran/spoor-enrichment","owner":{"login":"sarathjackendran","id":14014425,"avatar_url":"https://avatars.githubusercontent.com/u/14014425?v=3","gravatar_id":"","url":"https://api.github.com/users/sarathjackendran","html_url":"https://github.com/sarathjackendran","followers_url":"https://api.github.com/users/sarathjackendran/followers","following_url":"https://api.github.com/users/sarathjackendran/following{/other_user}","gists_url":"https://api.github.com/users/sarathjackendran/gists{/gist_id}","starred_url":"https://api.github.com/users/sarathjackendran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarathjackendran/subscriptions","organizations_url":"https://api.github.com/users/sarathjackendran/orgs","repos_url":"https://api.github.com/users/sarathjackendran/repos","events_url":"https://api.github.com/users/sarathjackendran/events{/privacy}","received_events_url":"https://api.github.com/users/sarathjackendran/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sarathjackendran/spoor-enrichment","description":"","fork":true,"url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment","forks_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/forks","keys_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/teams","hooks_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/hooks","issue_events_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/issues/events{/number}","events_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/events","assignees_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/assignees{/user}","branches_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/branches{/branch}","tags_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/tags","blobs_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/git/refs{/sha}","trees_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/statuses/{sha}","languages_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/languages","stargazers_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/stargazers","contributors_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/contributors","subscribers_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/subscribers","subscription_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/subscription","commits_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/commits{/sha}","git_commits_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/git/commits{/sha}","comments_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/comments{/number}","issue_comment_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/issues/comments{/number}","contents_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/contents/{+path}","compare_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/merges","archive_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/downloads","issues_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/issues{/number}","pulls_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/pulls{/number}","milestones_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/milestones{/number}","notifications_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/labels{/name}","releases_url":"https://api.github.com/repos/sarathjackendran/spoor-enrichment/releases{/id}","created_at":"2015-08-28T10:43:33Z","updated_at":"2015-08-28T10:43:33Z","pushed_at":"2015-08-31T10:54:35Z","git_url":"git://github.com/sarathjackendran/spoor-enrichment.git","ssh_url":"git@github.com:sarathjackendran/spoor-enrichment.git","clone_url":"https://github.com/sarathjackendran/spoor-enrichment.git","svn_url":"https://github.com/sarathjackendran/spoor-enrichment","homepage":null,"size":335,"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":"Financial-Times:master","ref":"master","sha":"0b42d988fedf10e192fb3b54449c400902cb1ee0","user":{"login":"Financial-Times","id":3502508,"avatar_url":"https://avatars.githubusercontent.com/u/3502508?v=3","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"repo":{"id":35812583,"name":"spoor-enrichment","full_name":"Financial-Times/spoor-enrichment","owner":{"login":"Financial-Times","id":3502508,"avatar_url":"https://avatars.githubusercontent.com/u/3502508?v=3","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Financial-Times/spoor-enrichment","description":"","fork":false,"url":"https://api.github.com/repos/Financial-Times/spoor-enrichment","forks_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/forks","keys_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/teams","hooks_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/hooks","issue_events_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/issues/events{/number}","events_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/events","assignees_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/assignees{/user}","branches_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/branches{/branch}","tags_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/tags","blobs_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/git/refs{/sha}","trees_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/statuses/{sha}","languages_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/languages","stargazers_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/stargazers","contributors_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/contributors","subscribers_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/subscribers","subscription_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/subscription","commits_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/commits{/sha}","git_commits_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/git/commits{/sha}","comments_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/comments{/number}","issue_comment_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/issues/comments{/number}","contents_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/contents/{+path}","compare_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/merges","archive_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/downloads","issues_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/issues{/number}","pulls_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls{/number}","milestones_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/milestones{/number}","notifications_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/labels{/name}","releases_url":"https://api.github.com/repos/Financial-Times/spoor-enrichment/releases{/id}","created_at":"2015-05-18T10:53:20Z","updated_at":"2015-06-02T16:36:01Z","pushed_at":"2015-09-01T15:10:20Z","git_url":"git://github.com/Financial-Times/spoor-enrichment.git","ssh_url":"git@github.com:Financial-Times/spoor-enrichment.git","clone_url":"https://github.com/Financial-Times/spoor-enrichment.git","svn_url":"https://github.com/Financial-Times/spoor-enrichment","homepage":null,"size":1214,"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":25,"forks":2,"open_issues":25,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/106"},"html":{"href":"https://github.com/Financial-Times/spoor-enrichment/pull/106"},"issue":{"href":"https://api.github.com/repos/Financial-Times/spoor-enrichment/issues/106"},"comments":{"href":"https://api.github.com/repos/Financial-Times/spoor-enrichment/issues/106/comments"},"review_comments":{"href":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/106/comments"},"review_comment":{"href":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Financial-Times/spoor-enrichment/pulls/106/commits"},"statuses":{"href":"https://api.github.com/repos/Financial-Times/spoor-enrichment/statuses/741715a672bf59e272d164096b21de02ef95a93b"}}}}