{"action":"created","comment":{"url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/comments/113499909","pull_request_review_id":34894166,"id":113499909,"diff_hunk":"@@ -0,0 +1,107 @@\n+require.scopes.stats = ( () => {\n+    var utils = require('utils'),\n+        statsByParentCompany = {},\n+        statsBySite = {},\n+        topBlocked = [];\n+\n+    function updateStatsFromTabData(tab){\n+        if(tab && tab.trackers && tab.trackers){\n+            Object.keys(tab.trackers).forEach(function(parentCompany){\n+                update(parentCompany, tab.url, tab.trackers[parentCompany]);\n+            });\n+        }\n+        // only sync when tab load completes. Should help avoid chrome.storage rate limts\n+        syncToStorage();\n+    }\n+\n+    function update(parentCompany, currentSite, tracker){\n+        currentSite = utils.extractHostFromURL(currentSite);\n+        addToParentCompanyStats(parentCompany, tracker);\n+        addToSiteStats(currentSite, tracker);\n+        calcTopBlocked(parentCompany);\n+    }\n+\n+    function addToParentCompanyStats(parentCompany, tracker){\n+        if(statsByParentCompany[parentCompany]){\n+            statsByParentCompany[parentCompany] += tracker.count;\n+        }\n+        else{\n+            statsByParentCompany[parentCompany] = tracker.count;\n+        }\n+    }\n+\n+    function addToSiteStats(site, tracker){\n+        var siteData = statsBySite[site] ? statsBySite[site] : {\"score\": null, \"trackers\": []};\n+        \n+        if(siteData.trackers.indexOf(tracker.url) === -1){\n+            siteData.trackers.push(tracker.url);\n+        }\n+        siteData.score = calcSiteScore(siteData);\n+        statsBySite[site] = siteData;\n+    }\n+\n+    function calcTopBlocked(parentCompany){\n+        var currIndex = topBlocked.indexOf(parentCompany);","path":"js/stats.js","position":44,"original_position":44,"commit_id":"9d798d057bb3fc699126ae8fc4f0138092bfbc65","original_commit_id":"9d798d057bb3fc699126ae8fc4f0138092bfbc65","user":{"login":"jdorweiler","id":1882892,"avatar_url":"https://avatars2.githubusercontent.com/u/1882892?v=3","gravatar_id":"","url":"https://api.github.com/users/jdorweiler","html_url":"https://github.com/jdorweiler","followers_url":"https://api.github.com/users/jdorweiler/followers","following_url":"https://api.github.com/users/jdorweiler/following{/other_user}","gists_url":"https://api.github.com/users/jdorweiler/gists{/gist_id}","starred_url":"https://api.github.com/users/jdorweiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdorweiler/subscriptions","organizations_url":"https://api.github.com/users/jdorweiler/orgs","repos_url":"https://api.github.com/users/jdorweiler/repos","events_url":"https://api.github.com/users/jdorweiler/events{/privacy}","received_events_url":"https://api.github.com/users/jdorweiler/received_events","type":"User","site_admin":false},"body":"with every update","created_at":"2017-04-26T16:26:30Z","updated_at":"2017-04-26T16:26:30Z","html_url":"https://github.com/duckduckgo/chrome-zeroclickinfo/pull/66#discussion_r113499909","pull_request_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/66","_links":{"self":{"href":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/comments/113499909"},"html":{"href":"https://github.com/duckduckgo/chrome-zeroclickinfo/pull/66#discussion_r113499909"},"pull_request":{"href":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/66"}}},"pull_request":{"url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/66","id":117719799,"html_url":"https://github.com/duckduckgo/chrome-zeroclickinfo/pull/66","diff_url":"https://github.com/duckduckgo/chrome-zeroclickinfo/pull/66.diff","patch_url":"https://github.com/duckduckgo/chrome-zeroclickinfo/pull/66.patch","issue_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/issues/66","number":66,"state":"open","locked":false,"title":"Store tracker stats","user":{"login":"jdorweiler","id":1882892,"avatar_url":"https://avatars2.githubusercontent.com/u/1882892?v=3","gravatar_id":"","url":"https://api.github.com/users/jdorweiler","html_url":"https://github.com/jdorweiler","followers_url":"https://api.github.com/users/jdorweiler/followers","following_url":"https://api.github.com/users/jdorweiler/following{/other_user}","gists_url":"https://api.github.com/users/jdorweiler/gists{/gist_id}","starred_url":"https://api.github.com/users/jdorweiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdorweiler/subscriptions","organizations_url":"https://api.github.com/users/jdorweiler/orgs","repos_url":"https://api.github.com/users/jdorweiler/repos","events_url":"https://api.github.com/users/jdorweiler/events{/privacy}","received_events_url":"https://api.github.com/users/jdorweiler/received_events","type":"User","site_admin":false},"body":"<!-- Please add the WIP label if the PR isn't complete. -->\r\n\r\n**Reviewer:**\r\n\r\n<!-- Optional fields\r\n**CC:**\r\n**Depends on:** \r\n-->\r\n\r\n## Description:\r\n<!-- Explain what is being changed, why, etc -->\r\n\r\n\r\n## Steps to test this PR:\r\n<!-- List steps to test it manually \r\n1. <STEP 1> \r\n-->\r\n\r\n## Automated tests:\r\n- [ ] Unit tests\r\n- [ ] Integration tests\r\n\r\n###### Reviewer Checklist:\r\n- [ ] **Ensure the PR solves the problem**\r\n- [ ] **Review every line of code**\r\n- [ ] **Ensure the PR does no harm by testing the changes thoroughly**\r\n- [ ] **Get help if you're uncomfortable with any of the above!**\r\n- [ ] Determine if there are any quick wins that improve the implementation\r\n\r\n\r\n###### PR Author Checklist:\r\n- [ ] Get advice or leverage existing code\r\n- [ ] Agree on technical approach with reviewer (if the changes are nuanced)\r\n- [ ] Ensure that there is a testing strategy (and documented non-automated tests)\r\n- [ ] Ensure there is a documented monitoring strategy (if necessary)\r\n- [ ] Consider systems implications \r\n","created_at":"2017-04-26T13:52:01Z","updated_at":"2017-04-26T16:26:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cdbdf44ddb39a831ada01eb74869b990dbcae2a0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/66/commits","review_comments_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/66/comments","review_comment_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/issues/66/comments","statuses_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/statuses/9d798d057bb3fc699126ae8fc4f0138092bfbc65","head":{"label":"duckduckgo:jd/stats","ref":"jd/stats","sha":"9d798d057bb3fc699126ae8fc4f0138092bfbc65","user":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars1.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"repo":{"id":3184563,"name":"chrome-zeroclickinfo","full_name":"duckduckgo/chrome-zeroclickinfo","owner":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars1.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/duckduckgo/chrome-zeroclickinfo","description":"Chrome Extension using the DuckDuckGo Zero-click Info API","fork":false,"url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo","forks_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/forks","keys_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/teams","hooks_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/hooks","issue_events_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/issues/events{/number}","events_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/events","assignees_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/assignees{/user}","branches_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/branches{/branch}","tags_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/tags","blobs_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/git/refs{/sha}","trees_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/statuses/{sha}","languages_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/languages","stargazers_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/stargazers","contributors_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/contributors","subscribers_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/subscribers","subscription_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/subscription","commits_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/commits{/sha}","git_commits_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/git/commits{/sha}","comments_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/comments{/number}","issue_comment_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/issues/comments{/number}","contents_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/contents/{+path}","compare_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/merges","archive_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/downloads","issues_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/issues{/number}","pulls_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls{/number}","milestones_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/milestones{/number}","notifications_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/labels{/name}","releases_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/releases{/id}","deployments_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/deployments","created_at":"2012-01-15T16:46:38Z","updated_at":"2017-04-21T20:48:19Z","pushed_at":"2017-04-26T14:59:32Z","git_url":"git://github.com/duckduckgo/chrome-zeroclickinfo.git","ssh_url":"git@github.com:duckduckgo/chrome-zeroclickinfo.git","clone_url":"https://github.com/duckduckgo/chrome-zeroclickinfo.git","svn_url":"https://github.com/duckduckgo/chrome-zeroclickinfo","homepage":"","size":53498,"stargazers_count":59,"watchers_count":59,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":10,"forks":34,"open_issues":10,"watchers":59,"default_branch":"master"}},"base":{"label":"duckduckgo:beta","ref":"beta","sha":"e621fd14080c25791332a9576dd8312d908d75b2","user":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars1.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"repo":{"id":3184563,"name":"chrome-zeroclickinfo","full_name":"duckduckgo/chrome-zeroclickinfo","owner":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars1.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/duckduckgo/chrome-zeroclickinfo","description":"Chrome Extension using the DuckDuckGo Zero-click Info API","fork":false,"url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo","forks_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/forks","keys_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/teams","hooks_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/hooks","issue_events_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/issues/events{/number}","events_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/events","assignees_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/assignees{/user}","branches_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/branches{/branch}","tags_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/tags","blobs_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/git/refs{/sha}","trees_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/statuses/{sha}","languages_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/languages","stargazers_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/stargazers","contributors_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/contributors","subscribers_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/subscribers","subscription_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/subscription","commits_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/commits{/sha}","git_commits_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/git/commits{/sha}","comments_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/comments{/number}","issue_comment_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/issues/comments{/number}","contents_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/contents/{+path}","compare_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/merges","archive_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/downloads","issues_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/issues{/number}","pulls_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls{/number}","milestones_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/milestones{/number}","notifications_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/labels{/name}","releases_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/releases{/id}","deployments_url":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/deployments","created_at":"2012-01-15T16:46:38Z","updated_at":"2017-04-21T20:48:19Z","pushed_at":"2017-04-26T14:59:32Z","git_url":"git://github.com/duckduckgo/chrome-zeroclickinfo.git","ssh_url":"git@github.com:duckduckgo/chrome-zeroclickinfo.git","clone_url":"https://github.com/duckduckgo/chrome-zeroclickinfo.git","svn_url":"https://github.com/duckduckgo/chrome-zeroclickinfo","homepage":"","size":53498,"stargazers_count":59,"watchers_count":59,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":10,"forks":34,"open_issues":10,"watchers":59,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/66"},"html":{"href":"https://github.com/duckduckgo/chrome-zeroclickinfo/pull/66"},"issue":{"href":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/issues/66"},"comments":{"href":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/duckduckgo/chrome-zeroclickinfo/statuses/9d798d057bb3fc699126ae8fc4f0138092bfbc65"}}}}
{"actor":{"display_login":"jdorweiler"}}