{"action":"created","comment":{"url":"https://api.github.com/repos/clearlydefined/service/pulls/comments/167389125","pull_request_review_id":95612438,"id":167389125,"diff_hunk":"@@ -0,0 +1,35 @@\n+// Copyright (c) 2018, The Linux Foundation. All rights reserved.\n+// SPDX-License-Identifier: MIT\n+\n+// Responsible for calculating what badge a component/definition has.\n+// For now we are just going to go with the simple:\n+// If license/copyright there it gets a 3. Only one of those it gets a 2. None, it gets a 1\n+\n+const _ = require('lodash');\n+\n+const scoreToUrl = {\n+  1: 'https://img.shields.io/badge/Clearly%20Defined%20Score-1-red.svg',\n+  2: 'https://img.shields.io/badge/Clearly%20Defined%20Score-2-yellow.svg',\n+  3: 'https://img.shields.io/badge/Clearly%20Defined%20Score-3-brightgreen.svg'\n+};\n+class BadgeCalculator {\n+  constructor(definition) {\n+    this.definition = definition;\n+  }\n+\n+  getBadgeUrl() {\n+    return scoreToUrl[this.calculate()];\n+  }\n+\n+  // @todo we need to flesh this out\n+  // For now it just checks that a license and copyright statements are present\n+  calculate() {\n+    const hasLicense = _.get(this.definition, 'licensed.license', false);\n+    const hasCopyright = _.get(this.definition, 'licensed.copyright.statements[0]', false);\n+    if (hasLicense && hasCopyright) {return 3;}","path":"business/badgeCalculator.js","position":29,"original_position":29,"commit_id":"423a064194bdeb555fa7d6b4da5a7d5923317a56","original_commit_id":"423a064194bdeb555fa7d6b4da5a7d5923317a56","user":{"login":"jeffmcaffer","id":10070956,"avatar_url":"https://avatars2.githubusercontent.com/u/10070956?v=4","gravatar_id":"","url":"https://api.github.com/users/jeffmcaffer","html_url":"https://github.com/jeffmcaffer","followers_url":"https://api.github.com/users/jeffmcaffer/followers","following_url":"https://api.github.com/users/jeffmcaffer/following{/other_user}","gists_url":"https://api.github.com/users/jeffmcaffer/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmcaffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmcaffer/subscriptions","organizations_url":"https://api.github.com/users/jeffmcaffer/orgs","repos_url":"https://api.github.com/users/jeffmcaffer/repos","events_url":"https://api.github.com/users/jeffmcaffer/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmcaffer/received_events","type":"User","site_admin":false},"body":"formatting. Convention would have this be \r\n```javascript\r\n   if (hasLicense && hasCopyright) \r\n     return 3;\r\n```","created_at":"2018-02-10T04:33:41Z","updated_at":"2018-02-10T04:45:50Z","html_url":"https://github.com/clearlydefined/service/pull/74#discussion_r167389125","pull_request_url":"https://api.github.com/repos/clearlydefined/service/pulls/74","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/clearlydefined/service/pulls/comments/167389125"},"html":{"href":"https://github.com/clearlydefined/service/pull/74#discussion_r167389125"},"pull_request":{"href":"https://api.github.com/repos/clearlydefined/service/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/clearlydefined/service/pulls/74","id":168373637,"html_url":"https://github.com/clearlydefined/service/pull/74","diff_url":"https://github.com/clearlydefined/service/pull/74.diff","patch_url":"https://github.com/clearlydefined/service/pull/74.patch","issue_url":"https://api.github.com/repos/clearlydefined/service/issues/74","number":74,"state":"open","locked":false,"title":"Add a /badges endpoint for displaying on your project site","user":{"login":"tesmart","id":35608706,"avatar_url":"https://avatars2.githubusercontent.com/u/35608706?v=4","gravatar_id":"","url":"https://api.github.com/users/tesmart","html_url":"https://github.com/tesmart","followers_url":"https://api.github.com/users/tesmart/followers","following_url":"https://api.github.com/users/tesmart/following{/other_user}","gists_url":"https://api.github.com/users/tesmart/gists{/gist_id}","starred_url":"https://api.github.com/users/tesmart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tesmart/subscriptions","organizations_url":"https://api.github.com/users/tesmart/orgs","repos_url":"https://api.github.com/users/tesmart/repos","events_url":"https://api.github.com/users/tesmart/events{/privacy}","received_events_url":"https://api.github.com/users/tesmart/received_events","type":"User","site_admin":false},"body":"This is a beginning. Perhaps later we can update the calculation logic to be a little more sophisticated.\r\n\r\nThanks to @jeffmcaffer @mynameistechno @cohenmax9 ","created_at":"2018-02-10T00:34:54Z","updated_at":"2018-02-10T04:45:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c0b7bd514f9a5690bcc1c819aee121e1688d42d2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/clearlydefined/service/pulls/74/commits","review_comments_url":"https://api.github.com/repos/clearlydefined/service/pulls/74/comments","review_comment_url":"https://api.github.com/repos/clearlydefined/service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clearlydefined/service/issues/74/comments","statuses_url":"https://api.github.com/repos/clearlydefined/service/statuses/423a064194bdeb555fa7d6b4da5a7d5923317a56","head":{"label":"codeauroraforum:add_badges","ref":"add_badges","sha":"423a064194bdeb555fa7d6b4da5a7d5923317a56","user":{"login":"codeauroraforum","id":801156,"avatar_url":"https://avatars2.githubusercontent.com/u/801156?v=4","gravatar_id":"","url":"https://api.github.com/users/codeauroraforum","html_url":"https://github.com/codeauroraforum","followers_url":"https://api.github.com/users/codeauroraforum/followers","following_url":"https://api.github.com/users/codeauroraforum/following{/other_user}","gists_url":"https://api.github.com/users/codeauroraforum/gists{/gist_id}","starred_url":"https://api.github.com/users/codeauroraforum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeauroraforum/subscriptions","organizations_url":"https://api.github.com/users/codeauroraforum/orgs","repos_url":"https://api.github.com/users/codeauroraforum/repos","events_url":"https://api.github.com/users/codeauroraforum/events{/privacy}","received_events_url":"https://api.github.com/users/codeauroraforum/received_events","type":"Organization","site_admin":false},"repo":{"id":113903330,"name":"service","full_name":"codeauroraforum/service","owner":{"login":"codeauroraforum","id":801156,"avatar_url":"https://avatars2.githubusercontent.com/u/801156?v=4","gravatar_id":"","url":"https://api.github.com/users/codeauroraforum","html_url":"https://github.com/codeauroraforum","followers_url":"https://api.github.com/users/codeauroraforum/followers","following_url":"https://api.github.com/users/codeauroraforum/following{/other_user}","gists_url":"https://api.github.com/users/codeauroraforum/gists{/gist_id}","starred_url":"https://api.github.com/users/codeauroraforum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeauroraforum/subscriptions","organizations_url":"https://api.github.com/users/codeauroraforum/orgs","repos_url":"https://api.github.com/users/codeauroraforum/repos","events_url":"https://api.github.com/users/codeauroraforum/events{/privacy}","received_events_url":"https://api.github.com/users/codeauroraforum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codeauroraforum/service","description":"The service side of clearlydefined.io","fork":true,"url":"https://api.github.com/repos/codeauroraforum/service","forks_url":"https://api.github.com/repos/codeauroraforum/service/forks","keys_url":"https://api.github.com/repos/codeauroraforum/service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codeauroraforum/service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codeauroraforum/service/teams","hooks_url":"https://api.github.com/repos/codeauroraforum/service/hooks","issue_events_url":"https://api.github.com/repos/codeauroraforum/service/issues/events{/number}","events_url":"https://api.github.com/repos/codeauroraforum/service/events","assignees_url":"https://api.github.com/repos/codeauroraforum/service/assignees{/user}","branches_url":"https://api.github.com/repos/codeauroraforum/service/branches{/branch}","tags_url":"https://api.github.com/repos/codeauroraforum/service/tags","blobs_url":"https://api.github.com/repos/codeauroraforum/service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codeauroraforum/service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codeauroraforum/service/git/refs{/sha}","trees_url":"https://api.github.com/repos/codeauroraforum/service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codeauroraforum/service/statuses/{sha}","languages_url":"https://api.github.com/repos/codeauroraforum/service/languages","stargazers_url":"https://api.github.com/repos/codeauroraforum/service/stargazers","contributors_url":"https://api.github.com/repos/codeauroraforum/service/contributors","subscribers_url":"https://api.github.com/repos/codeauroraforum/service/subscribers","subscription_url":"https://api.github.com/repos/codeauroraforum/service/subscription","commits_url":"https://api.github.com/repos/codeauroraforum/service/commits{/sha}","git_commits_url":"https://api.github.com/repos/codeauroraforum/service/git/commits{/sha}","comments_url":"https://api.github.com/repos/codeauroraforum/service/comments{/number}","issue_comment_url":"https://api.github.com/repos/codeauroraforum/service/issues/comments{/number}","contents_url":"https://api.github.com/repos/codeauroraforum/service/contents/{+path}","compare_url":"https://api.github.com/repos/codeauroraforum/service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codeauroraforum/service/merges","archive_url":"https://api.github.com/repos/codeauroraforum/service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codeauroraforum/service/downloads","issues_url":"https://api.github.com/repos/codeauroraforum/service/issues{/number}","pulls_url":"https://api.github.com/repos/codeauroraforum/service/pulls{/number}","milestones_url":"https://api.github.com/repos/codeauroraforum/service/milestones{/number}","notifications_url":"https://api.github.com/repos/codeauroraforum/service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codeauroraforum/service/labels{/name}","releases_url":"https://api.github.com/repos/codeauroraforum/service/releases{/id}","deployments_url":"https://api.github.com/repos/codeauroraforum/service/deployments","created_at":"2017-12-11T20:07:41Z","updated_at":"2017-12-13T20:24:47Z","pushed_at":"2018-02-10T00:37:50Z","git_url":"git://github.com/codeauroraforum/service.git","ssh_url":"git@github.com:codeauroraforum/service.git","clone_url":"https://github.com/codeauroraforum/service.git","svn_url":"https://github.com/codeauroraforum/service","homepage":null,"size":241,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"clearlydefined:master","ref":"master","sha":"1b76cec75428ecc5fbe87d5d3c91a5467514a0c5","user":{"login":"clearlydefined","id":34137144,"avatar_url":"https://avatars2.githubusercontent.com/u/34137144?v=4","gravatar_id":"","url":"https://api.github.com/users/clearlydefined","html_url":"https://github.com/clearlydefined","followers_url":"https://api.github.com/users/clearlydefined/followers","following_url":"https://api.github.com/users/clearlydefined/following{/other_user}","gists_url":"https://api.github.com/users/clearlydefined/gists{/gist_id}","starred_url":"https://api.github.com/users/clearlydefined/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearlydefined/subscriptions","organizations_url":"https://api.github.com/users/clearlydefined/orgs","repos_url":"https://api.github.com/users/clearlydefined/repos","events_url":"https://api.github.com/users/clearlydefined/events{/privacy}","received_events_url":"https://api.github.com/users/clearlydefined/received_events","type":"Organization","site_admin":false},"repo":{"id":113903008,"name":"service","full_name":"clearlydefined/service","owner":{"login":"clearlydefined","id":34137144,"avatar_url":"https://avatars2.githubusercontent.com/u/34137144?v=4","gravatar_id":"","url":"https://api.github.com/users/clearlydefined","html_url":"https://github.com/clearlydefined","followers_url":"https://api.github.com/users/clearlydefined/followers","following_url":"https://api.github.com/users/clearlydefined/following{/other_user}","gists_url":"https://api.github.com/users/clearlydefined/gists{/gist_id}","starred_url":"https://api.github.com/users/clearlydefined/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearlydefined/subscriptions","organizations_url":"https://api.github.com/users/clearlydefined/orgs","repos_url":"https://api.github.com/users/clearlydefined/repos","events_url":"https://api.github.com/users/clearlydefined/events{/privacy}","received_events_url":"https://api.github.com/users/clearlydefined/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clearlydefined/service","description":"The service side of clearlydefined.io","fork":false,"url":"https://api.github.com/repos/clearlydefined/service","forks_url":"https://api.github.com/repos/clearlydefined/service/forks","keys_url":"https://api.github.com/repos/clearlydefined/service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clearlydefined/service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clearlydefined/service/teams","hooks_url":"https://api.github.com/repos/clearlydefined/service/hooks","issue_events_url":"https://api.github.com/repos/clearlydefined/service/issues/events{/number}","events_url":"https://api.github.com/repos/clearlydefined/service/events","assignees_url":"https://api.github.com/repos/clearlydefined/service/assignees{/user}","branches_url":"https://api.github.com/repos/clearlydefined/service/branches{/branch}","tags_url":"https://api.github.com/repos/clearlydefined/service/tags","blobs_url":"https://api.github.com/repos/clearlydefined/service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clearlydefined/service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clearlydefined/service/git/refs{/sha}","trees_url":"https://api.github.com/repos/clearlydefined/service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clearlydefined/service/statuses/{sha}","languages_url":"https://api.github.com/repos/clearlydefined/service/languages","stargazers_url":"https://api.github.com/repos/clearlydefined/service/stargazers","contributors_url":"https://api.github.com/repos/clearlydefined/service/contributors","subscribers_url":"https://api.github.com/repos/clearlydefined/service/subscribers","subscription_url":"https://api.github.com/repos/clearlydefined/service/subscription","commits_url":"https://api.github.com/repos/clearlydefined/service/commits{/sha}","git_commits_url":"https://api.github.com/repos/clearlydefined/service/git/commits{/sha}","comments_url":"https://api.github.com/repos/clearlydefined/service/comments{/number}","issue_comment_url":"https://api.github.com/repos/clearlydefined/service/issues/comments{/number}","contents_url":"https://api.github.com/repos/clearlydefined/service/contents/{+path}","compare_url":"https://api.github.com/repos/clearlydefined/service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clearlydefined/service/merges","archive_url":"https://api.github.com/repos/clearlydefined/service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clearlydefined/service/downloads","issues_url":"https://api.github.com/repos/clearlydefined/service/issues{/number}","pulls_url":"https://api.github.com/repos/clearlydefined/service/pulls{/number}","milestones_url":"https://api.github.com/repos/clearlydefined/service/milestones{/number}","notifications_url":"https://api.github.com/repos/clearlydefined/service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clearlydefined/service/labels{/name}","releases_url":"https://api.github.com/repos/clearlydefined/service/releases{/id}","deployments_url":"https://api.github.com/repos/clearlydefined/service/deployments","created_at":"2017-12-11T20:04:11Z","updated_at":"2018-02-04T17:47:16Z","pushed_at":"2018-02-10T00:37:52Z","git_url":"git://github.com/clearlydefined/service.git","ssh_url":"git@github.com:clearlydefined/service.git","clone_url":"https://github.com/clearlydefined/service.git","svn_url":"https://github.com/clearlydefined/service","homepage":null,"size":241,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":21,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":21,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clearlydefined/service/pulls/74"},"html":{"href":"https://github.com/clearlydefined/service/pull/74"},"issue":{"href":"https://api.github.com/repos/clearlydefined/service/issues/74"},"comments":{"href":"https://api.github.com/repos/clearlydefined/service/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/clearlydefined/service/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/clearlydefined/service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clearlydefined/service/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/clearlydefined/service/statuses/423a064194bdeb555fa7d6b4da5a7d5923317a56"}},"author_association":"NONE"}}
{"actor":{"display_login":"jeffmcaffer"}}