{"action":"created","comment":{"url":"https://api.github.com/repos/opendatateam/udata/pulls/comments/82998368","pull_request_review_id":3864960,"id":82998368,"diff_hunk":"@@ -114,7 +114,7 @@ class MaxDatasetFollowersMetric(SiteMetric):\n     def get_value(self):\n         dataset = (Dataset.objects(metrics__followers__gt=0).visible()\n                           .order_by('-metrics.followers').first())\n-        return dataset.metrics.get('followers', 0)\n+        return dataset.metrics.get('followers', 0) if dataset else 0","path":"udata/core/site/metrics.py","position":5,"original_position":5,"commit_id":"39cd59d14432f9f2fa23126aeea81cb55a1270e7","original_commit_id":"39cd59d14432f9f2fa23126aeea81cb55a1270e7","user":{"login":"noirbizarre","id":15725,"avatar_url":"https://avatars.githubusercontent.com/u/15725?v=3","gravatar_id":"","url":"https://api.github.com/users/noirbizarre","html_url":"https://github.com/noirbizarre","followers_url":"https://api.github.com/users/noirbizarre/followers","following_url":"https://api.github.com/users/noirbizarre/following{/other_user}","gists_url":"https://api.github.com/users/noirbizarre/gists{/gist_id}","starred_url":"https://api.github.com/users/noirbizarre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noirbizarre/subscriptions","organizations_url":"https://api.github.com/users/noirbizarre/orgs","repos_url":"https://api.github.com/users/noirbizarre/repos","events_url":"https://api.github.com/users/noirbizarre/events{/privacy}","received_events_url":"https://api.github.com/users/noirbizarre/received_events","type":"User","site_admin":false},"body":"Your fix is right but I believe that `metrics_followers__gt=0` ensure there is always a `followers` metric if there is a matching dataset so you can write:\r\n```python\r\nreturn dataset.metrics['followers'] if dataset else 0\r\n```","created_at":"2016-10-12T12:56:25Z","updated_at":"2016-10-12T12:56:39Z","html_url":"https://github.com/opendatateam/udata/pull/558#discussion_r82998368","pull_request_url":"https://api.github.com/repos/opendatateam/udata/pulls/558","_links":{"self":{"href":"https://api.github.com/repos/opendatateam/udata/pulls/comments/82998368"},"html":{"href":"https://github.com/opendatateam/udata/pull/558#discussion_r82998368"},"pull_request":{"href":"https://api.github.com/repos/opendatateam/udata/pulls/558"}}},"pull_request":{"url":"https://api.github.com/repos/opendatateam/udata/pulls/558","id":88998452,"html_url":"https://github.com/opendatateam/udata/pull/558","diff_url":"https://github.com/opendatateam/udata/pull/558.diff","patch_url":"https://github.com/opendatateam/udata/pull/558.patch","issue_url":"https://api.github.com/repos/opendatateam/udata/issues/558","number":558,"state":"open","locked":false,"title":"Fix erroneous user statistics in the admin (fixes #539)","user":{"login":"jphnoel","id":7070530,"avatar_url":"https://avatars.githubusercontent.com/u/7070530?v=3","gravatar_id":"","url":"https://api.github.com/users/jphnoel","html_url":"https://github.com/jphnoel","followers_url":"https://api.github.com/users/jphnoel/followers","following_url":"https://api.github.com/users/jphnoel/following{/other_user}","gists_url":"https://api.github.com/users/jphnoel/gists{/gist_id}","starred_url":"https://api.github.com/users/jphnoel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jphnoel/subscriptions","organizations_url":"https://api.github.com/users/jphnoel/orgs","repos_url":"https://api.github.com/users/jphnoel/repos","events_url":"https://api.github.com/users/jphnoel/events{/privacy}","received_events_url":"https://api.github.com/users/jphnoel/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-12T11:26:31Z","updated_at":"2016-10-12T12:56:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fb217805e220ab04db38482104c5eff1696f3bd2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/opendatateam/udata/pulls/558/commits","review_comments_url":"https://api.github.com/repos/opendatateam/udata/pulls/558/comments","review_comment_url":"https://api.github.com/repos/opendatateam/udata/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opendatateam/udata/issues/558/comments","statuses_url":"https://api.github.com/repos/opendatateam/udata/statuses/39cd59d14432f9f2fa23126aeea81cb55a1270e7","head":{"label":"jphnoel:539","ref":"539","sha":"39cd59d14432f9f2fa23126aeea81cb55a1270e7","user":{"login":"jphnoel","id":7070530,"avatar_url":"https://avatars.githubusercontent.com/u/7070530?v=3","gravatar_id":"","url":"https://api.github.com/users/jphnoel","html_url":"https://github.com/jphnoel","followers_url":"https://api.github.com/users/jphnoel/followers","following_url":"https://api.github.com/users/jphnoel/following{/other_user}","gists_url":"https://api.github.com/users/jphnoel/gists{/gist_id}","starred_url":"https://api.github.com/users/jphnoel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jphnoel/subscriptions","organizations_url":"https://api.github.com/users/jphnoel/orgs","repos_url":"https://api.github.com/users/jphnoel/repos","events_url":"https://api.github.com/users/jphnoel/events{/privacy}","received_events_url":"https://api.github.com/users/jphnoel/received_events","type":"User","site_admin":false},"repo":{"id":67027070,"name":"udata","full_name":"jphnoel/udata","owner":{"login":"jphnoel","id":7070530,"avatar_url":"https://avatars.githubusercontent.com/u/7070530?v=3","gravatar_id":"","url":"https://api.github.com/users/jphnoel","html_url":"https://github.com/jphnoel","followers_url":"https://api.github.com/users/jphnoel/followers","following_url":"https://api.github.com/users/jphnoel/following{/other_user}","gists_url":"https://api.github.com/users/jphnoel/gists{/gist_id}","starred_url":"https://api.github.com/users/jphnoel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jphnoel/subscriptions","organizations_url":"https://api.github.com/users/jphnoel/orgs","repos_url":"https://api.github.com/users/jphnoel/repos","events_url":"https://api.github.com/users/jphnoel/events{/privacy}","received_events_url":"https://api.github.com/users/jphnoel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jphnoel/udata","description":"Customizable and skinnable social platform dedicated to (open)data.","fork":true,"url":"https://api.github.com/repos/jphnoel/udata","forks_url":"https://api.github.com/repos/jphnoel/udata/forks","keys_url":"https://api.github.com/repos/jphnoel/udata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jphnoel/udata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jphnoel/udata/teams","hooks_url":"https://api.github.com/repos/jphnoel/udata/hooks","issue_events_url":"https://api.github.com/repos/jphnoel/udata/issues/events{/number}","events_url":"https://api.github.com/repos/jphnoel/udata/events","assignees_url":"https://api.github.com/repos/jphnoel/udata/assignees{/user}","branches_url":"https://api.github.com/repos/jphnoel/udata/branches{/branch}","tags_url":"https://api.github.com/repos/jphnoel/udata/tags","blobs_url":"https://api.github.com/repos/jphnoel/udata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jphnoel/udata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jphnoel/udata/git/refs{/sha}","trees_url":"https://api.github.com/repos/jphnoel/udata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jphnoel/udata/statuses/{sha}","languages_url":"https://api.github.com/repos/jphnoel/udata/languages","stargazers_url":"https://api.github.com/repos/jphnoel/udata/stargazers","contributors_url":"https://api.github.com/repos/jphnoel/udata/contributors","subscribers_url":"https://api.github.com/repos/jphnoel/udata/subscribers","subscription_url":"https://api.github.com/repos/jphnoel/udata/subscription","commits_url":"https://api.github.com/repos/jphnoel/udata/commits{/sha}","git_commits_url":"https://api.github.com/repos/jphnoel/udata/git/commits{/sha}","comments_url":"https://api.github.com/repos/jphnoel/udata/comments{/number}","issue_comment_url":"https://api.github.com/repos/jphnoel/udata/issues/comments{/number}","contents_url":"https://api.github.com/repos/jphnoel/udata/contents/{+path}","compare_url":"https://api.github.com/repos/jphnoel/udata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jphnoel/udata/merges","archive_url":"https://api.github.com/repos/jphnoel/udata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jphnoel/udata/downloads","issues_url":"https://api.github.com/repos/jphnoel/udata/issues{/number}","pulls_url":"https://api.github.com/repos/jphnoel/udata/pulls{/number}","milestones_url":"https://api.github.com/repos/jphnoel/udata/milestones{/number}","notifications_url":"https://api.github.com/repos/jphnoel/udata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jphnoel/udata/labels{/name}","releases_url":"https://api.github.com/repos/jphnoel/udata/releases{/id}","deployments_url":"https://api.github.com/repos/jphnoel/udata/deployments","created_at":"2016-08-31T10:15:53Z","updated_at":"2016-08-31T10:15:55Z","pushed_at":"2016-10-12T11:25:15Z","git_url":"git://github.com/jphnoel/udata.git","ssh_url":"git@github.com:jphnoel/udata.git","clone_url":"https://github.com/jphnoel/udata.git","svn_url":"https://github.com/jphnoel/udata","homepage":"http://udata.readthedocs.org","size":7348,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"opendatateam:dev","ref":"dev","sha":"5d65c99d250edc84793d09c4ddddf39fbfce1a3a","user":{"login":"opendatateam","id":19330690,"avatar_url":"https://avatars.githubusercontent.com/u/19330690?v=3","gravatar_id":"","url":"https://api.github.com/users/opendatateam","html_url":"https://github.com/opendatateam","followers_url":"https://api.github.com/users/opendatateam/followers","following_url":"https://api.github.com/users/opendatateam/following{/other_user}","gists_url":"https://api.github.com/users/opendatateam/gists{/gist_id}","starred_url":"https://api.github.com/users/opendatateam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opendatateam/subscriptions","organizations_url":"https://api.github.com/users/opendatateam/orgs","repos_url":"https://api.github.com/users/opendatateam/repos","events_url":"https://api.github.com/users/opendatateam/events{/privacy}","received_events_url":"https://api.github.com/users/opendatateam/received_events","type":"Organization","site_admin":false},"repo":{"id":19141754,"name":"udata","full_name":"opendatateam/udata","owner":{"login":"opendatateam","id":19330690,"avatar_url":"https://avatars.githubusercontent.com/u/19330690?v=3","gravatar_id":"","url":"https://api.github.com/users/opendatateam","html_url":"https://github.com/opendatateam","followers_url":"https://api.github.com/users/opendatateam/followers","following_url":"https://api.github.com/users/opendatateam/following{/other_user}","gists_url":"https://api.github.com/users/opendatateam/gists{/gist_id}","starred_url":"https://api.github.com/users/opendatateam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opendatateam/subscriptions","organizations_url":"https://api.github.com/users/opendatateam/orgs","repos_url":"https://api.github.com/users/opendatateam/repos","events_url":"https://api.github.com/users/opendatateam/events{/privacy}","received_events_url":"https://api.github.com/users/opendatateam/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opendatateam/udata","description":"Customizable and skinnable social platform dedicated to (open)data.","fork":false,"url":"https://api.github.com/repos/opendatateam/udata","forks_url":"https://api.github.com/repos/opendatateam/udata/forks","keys_url":"https://api.github.com/repos/opendatateam/udata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opendatateam/udata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opendatateam/udata/teams","hooks_url":"https://api.github.com/repos/opendatateam/udata/hooks","issue_events_url":"https://api.github.com/repos/opendatateam/udata/issues/events{/number}","events_url":"https://api.github.com/repos/opendatateam/udata/events","assignees_url":"https://api.github.com/repos/opendatateam/udata/assignees{/user}","branches_url":"https://api.github.com/repos/opendatateam/udata/branches{/branch}","tags_url":"https://api.github.com/repos/opendatateam/udata/tags","blobs_url":"https://api.github.com/repos/opendatateam/udata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opendatateam/udata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opendatateam/udata/git/refs{/sha}","trees_url":"https://api.github.com/repos/opendatateam/udata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opendatateam/udata/statuses/{sha}","languages_url":"https://api.github.com/repos/opendatateam/udata/languages","stargazers_url":"https://api.github.com/repos/opendatateam/udata/stargazers","contributors_url":"https://api.github.com/repos/opendatateam/udata/contributors","subscribers_url":"https://api.github.com/repos/opendatateam/udata/subscribers","subscription_url":"https://api.github.com/repos/opendatateam/udata/subscription","commits_url":"https://api.github.com/repos/opendatateam/udata/commits{/sha}","git_commits_url":"https://api.github.com/repos/opendatateam/udata/git/commits{/sha}","comments_url":"https://api.github.com/repos/opendatateam/udata/comments{/number}","issue_comment_url":"https://api.github.com/repos/opendatateam/udata/issues/comments{/number}","contents_url":"https://api.github.com/repos/opendatateam/udata/contents/{+path}","compare_url":"https://api.github.com/repos/opendatateam/udata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opendatateam/udata/merges","archive_url":"https://api.github.com/repos/opendatateam/udata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opendatateam/udata/downloads","issues_url":"https://api.github.com/repos/opendatateam/udata/issues{/number}","pulls_url":"https://api.github.com/repos/opendatateam/udata/pulls{/number}","milestones_url":"https://api.github.com/repos/opendatateam/udata/milestones{/number}","notifications_url":"https://api.github.com/repos/opendatateam/udata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opendatateam/udata/labels{/name}","releases_url":"https://api.github.com/repos/opendatateam/udata/releases{/id}","deployments_url":"https://api.github.com/repos/opendatateam/udata/deployments","created_at":"2014-04-25T09:57:34Z","updated_at":"2016-10-09T20:30:09Z","pushed_at":"2016-10-12T11:26:31Z","git_url":"git://github.com/opendatateam/udata.git","ssh_url":"git@github.com:opendatateam/udata.git","clone_url":"https://github.com/opendatateam/udata.git","svn_url":"https://github.com/opendatateam/udata","homepage":"http://udata.readthedocs.org","size":7811,"stargazers_count":45,"watchers_count":45,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":38,"forks":21,"open_issues":38,"watchers":45,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/opendatateam/udata/pulls/558"},"html":{"href":"https://github.com/opendatateam/udata/pull/558"},"issue":{"href":"https://api.github.com/repos/opendatateam/udata/issues/558"},"comments":{"href":"https://api.github.com/repos/opendatateam/udata/issues/558/comments"},"review_comments":{"href":"https://api.github.com/repos/opendatateam/udata/pulls/558/comments"},"review_comment":{"href":"https://api.github.com/repos/opendatateam/udata/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opendatateam/udata/pulls/558/commits"},"statuses":{"href":"https://api.github.com/repos/opendatateam/udata/statuses/39cd59d14432f9f2fa23126aeea81cb55a1270e7"}}}}
{"actor":{"display_login":"noirbizarre"}}