{"action":"created","comment":{"url":"https://api.github.com/repos/debkbanerji/templyte/pulls/comments/226749175","pull_request_review_id":166652540,"id":226749175,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjc0OTE3NQ==","diff_hunk":"@@ -68,6 +73,45 @@ export class DownloadTemplateComponent implements OnInit {\n         this.authService.logout(null);\n     }\n \n+    storeRating(new_rating) {\n+        const component = this;\n+        const authorUID:string  =  component.user.uid;\n+        component.templateRatingsInfoDatabaseRef.once('value').then(snapshot2 => {\n+            const old_rating = snapshot2.val(); //value of previous rating\n+            var varNumRatings = 0;\n+            var varRatingSum = 0;\n+            component.templateRatingsInfoDatabaseRef.set(\n+                 new_rating\n+            );\n+            let hasRated:boolean = old_rating != null;\n+            if (hasRated) {\n+                component.templateDirectoryInfoDatabaseRef.child('/ratingSum').transaction(function(ratingSum){\n+                    varRatingSum = ratingSum - old_rating + new_rating;\n+                    return ratingSum - old_rating + new_rating;\n+                }).then(function(ratingSum) {\n+                    varNumRatings = 1;\n+                    component.templateDirectoryInfoDatabaseRef.child('/averageRating').transaction(function(avgRating){\n+                            return (varRatingSum * 1.0) / varNumRatings;\n+                    });\n+                });\n+            } else {\n+                component.templateDirectoryInfoDatabaseRef.child('/numberRatings').transaction(function(numberRatings){\n+                    varNumRatings = numberRatings + 1;\n+                    return numberRatings + 1;\n+                }).then(function(ratingSum) {\n+                    component.templateDirectoryInfoDatabaseRef.child('/ratingSum').transaction(function(ratingSum){","path":"static/templyte/src/app/download-template/download-template.component.ts","position":80,"original_position":80,"commit_id":"b1febc5359b0e3f6803e5372afa165a23073c1bd","original_commit_id":"b1febc5359b0e3f6803e5372afa165a23073c1bd","user":{"login":"debkbanerji","id":14082259,"node_id":"MDQ6VXNlcjE0MDgyMjU5","avatar_url":"https://avatars3.githubusercontent.com/u/14082259?v=4","gravatar_id":"","url":"https://api.github.com/users/debkbanerji","html_url":"https://github.com/debkbanerji","followers_url":"https://api.github.com/users/debkbanerji/followers","following_url":"https://api.github.com/users/debkbanerji/following{/other_user}","gists_url":"https://api.github.com/users/debkbanerji/gists{/gist_id}","starred_url":"https://api.github.com/users/debkbanerji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/debkbanerji/subscriptions","organizations_url":"https://api.github.com/users/debkbanerji/orgs","repos_url":"https://api.github.com/users/debkbanerji/repos","events_url":"https://api.github.com/users/debkbanerji/events{/privacy}","received_events_url":"https://api.github.com/users/debkbanerji/received_events","type":"User","site_admin":false},"body":"Shadowed name - dangerous","created_at":"2018-10-19T18:55:47Z","updated_at":"2018-10-19T18:59:53Z","html_url":"https://github.com/debkbanerji/templyte/pull/51#discussion_r226749175","pull_request_url":"https://api.github.com/repos/debkbanerji/templyte/pulls/51","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/debkbanerji/templyte/pulls/comments/226749175"},"html":{"href":"https://github.com/debkbanerji/templyte/pull/51#discussion_r226749175"},"pull_request":{"href":"https://api.github.com/repos/debkbanerji/templyte/pulls/51"}}},"pull_request":{"url":"https://api.github.com/repos/debkbanerji/templyte/pulls/51","id":222737502,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIyNzM3NTAy","html_url":"https://github.com/debkbanerji/templyte/pull/51","diff_url":"https://github.com/debkbanerji/templyte/pull/51.diff","patch_url":"https://github.com/debkbanerji/templyte/pull/51.patch","issue_url":"https://api.github.com/repos/debkbanerji/templyte/issues/51","number":51,"state":"open","locked":false,"title":"Ratings","user":{"login":"15AshwiniI","id":4958744,"node_id":"MDQ6VXNlcjQ5NTg3NDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/4958744?v=4","gravatar_id":"","url":"https://api.github.com/users/15AshwiniI","html_url":"https://github.com/15AshwiniI","followers_url":"https://api.github.com/users/15AshwiniI/followers","following_url":"https://api.github.com/users/15AshwiniI/following{/other_user}","gists_url":"https://api.github.com/users/15AshwiniI/gists{/gist_id}","starred_url":"https://api.github.com/users/15AshwiniI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/15AshwiniI/subscriptions","organizations_url":"https://api.github.com/users/15AshwiniI/orgs","repos_url":"https://api.github.com/users/15AshwiniI/repos","events_url":"https://api.github.com/users/15AshwiniI/events{/privacy}","received_events_url":"https://api.github.com/users/15AshwiniI/received_events","type":"User","site_admin":false},"body":"A user can rate a template from the downloads page. If the user has already rated that template, the new rating is saved in template-ratings. They cannot make a rating lower than 1. The total number of ratings, sum, and average are also stored in the tempate-directory. ","created_at":"2018-10-14T19:29:45Z","updated_at":"2018-10-19T18:59:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1d9a1a711f48d06e5846443e6d114661615d1baa","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/debkbanerji/templyte/pulls/51/commits","review_comments_url":"https://api.github.com/repos/debkbanerji/templyte/pulls/51/comments","review_comment_url":"https://api.github.com/repos/debkbanerji/templyte/pulls/comments{/number}","comments_url":"https://api.github.com/repos/debkbanerji/templyte/issues/51/comments","statuses_url":"https://api.github.com/repos/debkbanerji/templyte/statuses/b1febc5359b0e3f6803e5372afa165a23073c1bd","head":{"label":"debkbanerji:ratings","ref":"ratings","sha":"b1febc5359b0e3f6803e5372afa165a23073c1bd","user":{"login":"debkbanerji","id":14082259,"node_id":"MDQ6VXNlcjE0MDgyMjU5","avatar_url":"https://avatars3.githubusercontent.com/u/14082259?v=4","gravatar_id":"","url":"https://api.github.com/users/debkbanerji","html_url":"https://github.com/debkbanerji","followers_url":"https://api.github.com/users/debkbanerji/followers","following_url":"https://api.github.com/users/debkbanerji/following{/other_user}","gists_url":"https://api.github.com/users/debkbanerji/gists{/gist_id}","starred_url":"https://api.github.com/users/debkbanerji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/debkbanerji/subscriptions","organizations_url":"https://api.github.com/users/debkbanerji/orgs","repos_url":"https://api.github.com/users/debkbanerji/repos","events_url":"https://api.github.com/users/debkbanerji/events{/privacy}","received_events_url":"https://api.github.com/users/debkbanerji/received_events","type":"User","site_admin":false},"repo":{"id":145568073,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU1NjgwNzM=","name":"templyte","full_name":"debkbanerji/templyte","private":false,"owner":{"login":"debkbanerji","id":14082259,"node_id":"MDQ6VXNlcjE0MDgyMjU5","avatar_url":"https://avatars3.githubusercontent.com/u/14082259?v=4","gravatar_id":"","url":"https://api.github.com/users/debkbanerji","html_url":"https://github.com/debkbanerji","followers_url":"https://api.github.com/users/debkbanerji/followers","following_url":"https://api.github.com/users/debkbanerji/following{/other_user}","gists_url":"https://api.github.com/users/debkbanerji/gists{/gist_id}","starred_url":"https://api.github.com/users/debkbanerji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/debkbanerji/subscriptions","organizations_url":"https://api.github.com/users/debkbanerji/orgs","repos_url":"https://api.github.com/users/debkbanerji/repos","events_url":"https://api.github.com/users/debkbanerji/events{/privacy}","received_events_url":"https://api.github.com/users/debkbanerji/received_events","type":"User","site_admin":false},"html_url":"https://github.com/debkbanerji/templyte","description":"Junior Design Project","fork":false,"url":"https://api.github.com/repos/debkbanerji/templyte","forks_url":"https://api.github.com/repos/debkbanerji/templyte/forks","keys_url":"https://api.github.com/repos/debkbanerji/templyte/keys{/key_id}","collaborators_url":"https://api.github.com/repos/debkbanerji/templyte/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/debkbanerji/templyte/teams","hooks_url":"https://api.github.com/repos/debkbanerji/templyte/hooks","issue_events_url":"https://api.github.com/repos/debkbanerji/templyte/issues/events{/number}","events_url":"https://api.github.com/repos/debkbanerji/templyte/events","assignees_url":"https://api.github.com/repos/debkbanerji/templyte/assignees{/user}","branches_url":"https://api.github.com/repos/debkbanerji/templyte/branches{/branch}","tags_url":"https://api.github.com/repos/debkbanerji/templyte/tags","blobs_url":"https://api.github.com/repos/debkbanerji/templyte/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/debkbanerji/templyte/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/debkbanerji/templyte/git/refs{/sha}","trees_url":"https://api.github.com/repos/debkbanerji/templyte/git/trees{/sha}","statuses_url":"https://api.github.com/repos/debkbanerji/templyte/statuses/{sha}","languages_url":"https://api.github.com/repos/debkbanerji/templyte/languages","stargazers_url":"https://api.github.com/repos/debkbanerji/templyte/stargazers","contributors_url":"https://api.github.com/repos/debkbanerji/templyte/contributors","subscribers_url":"https://api.github.com/repos/debkbanerji/templyte/subscribers","subscription_url":"https://api.github.com/repos/debkbanerji/templyte/subscription","commits_url":"https://api.github.com/repos/debkbanerji/templyte/commits{/sha}","git_commits_url":"https://api.github.com/repos/debkbanerji/templyte/git/commits{/sha}","comments_url":"https://api.github.com/repos/debkbanerji/templyte/comments{/number}","issue_comment_url":"https://api.github.com/repos/debkbanerji/templyte/issues/comments{/number}","contents_url":"https://api.github.com/repos/debkbanerji/templyte/contents/{+path}","compare_url":"https://api.github.com/repos/debkbanerji/templyte/compare/{base}...{head}","merges_url":"https://api.github.com/repos/debkbanerji/templyte/merges","archive_url":"https://api.github.com/repos/debkbanerji/templyte/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/debkbanerji/templyte/downloads","issues_url":"https://api.github.com/repos/debkbanerji/templyte/issues{/number}","pulls_url":"https://api.github.com/repos/debkbanerji/templyte/pulls{/number}","milestones_url":"https://api.github.com/repos/debkbanerji/templyte/milestones{/number}","notifications_url":"https://api.github.com/repos/debkbanerji/templyte/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/debkbanerji/templyte/labels{/name}","releases_url":"https://api.github.com/repos/debkbanerji/templyte/releases{/id}","deployments_url":"https://api.github.com/repos/debkbanerji/templyte/deployments","created_at":"2018-08-21T13:30:45Z","updated_at":"2018-10-19T18:43:09Z","pushed_at":"2018-10-19T18:43:07Z","git_url":"git://github.com/debkbanerji/templyte.git","ssh_url":"git@github.com:debkbanerji/templyte.git","clone_url":"https://github.com/debkbanerji/templyte.git","svn_url":"https://github.com/debkbanerji/templyte","homepage":null,"size":5677,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":24,"license":null,"forks":0,"open_issues":24,"watchers":0,"default_branch":"master"}},"base":{"label":"debkbanerji:master","ref":"master","sha":"6baf4efb4ac6578a5a25b9622ddd8cd9b53a1a7c","user":{"login":"debkbanerji","id":14082259,"node_id":"MDQ6VXNlcjE0MDgyMjU5","avatar_url":"https://avatars3.githubusercontent.com/u/14082259?v=4","gravatar_id":"","url":"https://api.github.com/users/debkbanerji","html_url":"https://github.com/debkbanerji","followers_url":"https://api.github.com/users/debkbanerji/followers","following_url":"https://api.github.com/users/debkbanerji/following{/other_user}","gists_url":"https://api.github.com/users/debkbanerji/gists{/gist_id}","starred_url":"https://api.github.com/users/debkbanerji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/debkbanerji/subscriptions","organizations_url":"https://api.github.com/users/debkbanerji/orgs","repos_url":"https://api.github.com/users/debkbanerji/repos","events_url":"https://api.github.com/users/debkbanerji/events{/privacy}","received_events_url":"https://api.github.com/users/debkbanerji/received_events","type":"User","site_admin":false},"repo":{"id":145568073,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU1NjgwNzM=","name":"templyte","full_name":"debkbanerji/templyte","private":false,"owner":{"login":"debkbanerji","id":14082259,"node_id":"MDQ6VXNlcjE0MDgyMjU5","avatar_url":"https://avatars3.githubusercontent.com/u/14082259?v=4","gravatar_id":"","url":"https://api.github.com/users/debkbanerji","html_url":"https://github.com/debkbanerji","followers_url":"https://api.github.com/users/debkbanerji/followers","following_url":"https://api.github.com/users/debkbanerji/following{/other_user}","gists_url":"https://api.github.com/users/debkbanerji/gists{/gist_id}","starred_url":"https://api.github.com/users/debkbanerji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/debkbanerji/subscriptions","organizations_url":"https://api.github.com/users/debkbanerji/orgs","repos_url":"https://api.github.com/users/debkbanerji/repos","events_url":"https://api.github.com/users/debkbanerji/events{/privacy}","received_events_url":"https://api.github.com/users/debkbanerji/received_events","type":"User","site_admin":false},"html_url":"https://github.com/debkbanerji/templyte","description":"Junior Design Project","fork":false,"url":"https://api.github.com/repos/debkbanerji/templyte","forks_url":"https://api.github.com/repos/debkbanerji/templyte/forks","keys_url":"https://api.github.com/repos/debkbanerji/templyte/keys{/key_id}","collaborators_url":"https://api.github.com/repos/debkbanerji/templyte/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/debkbanerji/templyte/teams","hooks_url":"https://api.github.com/repos/debkbanerji/templyte/hooks","issue_events_url":"https://api.github.com/repos/debkbanerji/templyte/issues/events{/number}","events_url":"https://api.github.com/repos/debkbanerji/templyte/events","assignees_url":"https://api.github.com/repos/debkbanerji/templyte/assignees{/user}","branches_url":"https://api.github.com/repos/debkbanerji/templyte/branches{/branch}","tags_url":"https://api.github.com/repos/debkbanerji/templyte/tags","blobs_url":"https://api.github.com/repos/debkbanerji/templyte/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/debkbanerji/templyte/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/debkbanerji/templyte/git/refs{/sha}","trees_url":"https://api.github.com/repos/debkbanerji/templyte/git/trees{/sha}","statuses_url":"https://api.github.com/repos/debkbanerji/templyte/statuses/{sha}","languages_url":"https://api.github.com/repos/debkbanerji/templyte/languages","stargazers_url":"https://api.github.com/repos/debkbanerji/templyte/stargazers","contributors_url":"https://api.github.com/repos/debkbanerji/templyte/contributors","subscribers_url":"https://api.github.com/repos/debkbanerji/templyte/subscribers","subscription_url":"https://api.github.com/repos/debkbanerji/templyte/subscription","commits_url":"https://api.github.com/repos/debkbanerji/templyte/commits{/sha}","git_commits_url":"https://api.github.com/repos/debkbanerji/templyte/git/commits{/sha}","comments_url":"https://api.github.com/repos/debkbanerji/templyte/comments{/number}","issue_comment_url":"https://api.github.com/repos/debkbanerji/templyte/issues/comments{/number}","contents_url":"https://api.github.com/repos/debkbanerji/templyte/contents/{+path}","compare_url":"https://api.github.com/repos/debkbanerji/templyte/compare/{base}...{head}","merges_url":"https://api.github.com/repos/debkbanerji/templyte/merges","archive_url":"https://api.github.com/repos/debkbanerji/templyte/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/debkbanerji/templyte/downloads","issues_url":"https://api.github.com/repos/debkbanerji/templyte/issues{/number}","pulls_url":"https://api.github.com/repos/debkbanerji/templyte/pulls{/number}","milestones_url":"https://api.github.com/repos/debkbanerji/templyte/milestones{/number}","notifications_url":"https://api.github.com/repos/debkbanerji/templyte/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/debkbanerji/templyte/labels{/name}","releases_url":"https://api.github.com/repos/debkbanerji/templyte/releases{/id}","deployments_url":"https://api.github.com/repos/debkbanerji/templyte/deployments","created_at":"2018-08-21T13:30:45Z","updated_at":"2018-10-19T18:43:09Z","pushed_at":"2018-10-19T18:43:07Z","git_url":"git://github.com/debkbanerji/templyte.git","ssh_url":"git@github.com:debkbanerji/templyte.git","clone_url":"https://github.com/debkbanerji/templyte.git","svn_url":"https://github.com/debkbanerji/templyte","homepage":null,"size":5677,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":24,"license":null,"forks":0,"open_issues":24,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/debkbanerji/templyte/pulls/51"},"html":{"href":"https://github.com/debkbanerji/templyte/pull/51"},"issue":{"href":"https://api.github.com/repos/debkbanerji/templyte/issues/51"},"comments":{"href":"https://api.github.com/repos/debkbanerji/templyte/issues/51/comments"},"review_comments":{"href":"https://api.github.com/repos/debkbanerji/templyte/pulls/51/comments"},"review_comment":{"href":"https://api.github.com/repos/debkbanerji/templyte/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/debkbanerji/templyte/pulls/51/commits"},"statuses":{"href":"https://api.github.com/repos/debkbanerji/templyte/statuses/b1febc5359b0e3f6803e5372afa165a23073c1bd"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"debkbanerji"}}