{"action":"created","issue":{"url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1259","repository_url":"https://api.github.com/repos/rubygems/rubygems.org","labels_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1259/labels{/name}","comments_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1259/comments","events_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1259/events","html_url":"https://github.com/rubygems/rubygems.org/pull/1259","id":152196569,"number":1259,"title":"Prevent stats page error when no downloads","user":{"login":"BobWhitelock","id":7476523,"avatar_url":"https://avatars.githubusercontent.com/u/7476523?v=3","gravatar_id":"","url":"https://api.github.com/users/BobWhitelock","html_url":"https://github.com/BobWhitelock","followers_url":"https://api.github.com/users/BobWhitelock/followers","following_url":"https://api.github.com/users/BobWhitelock/following{/other_user}","gists_url":"https://api.github.com/users/BobWhitelock/gists{/gist_id}","starred_url":"https://api.github.com/users/BobWhitelock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BobWhitelock/subscriptions","organizations_url":"https://api.github.com/users/BobWhitelock/orgs","repos_url":"https://api.github.com/users/BobWhitelock/repos","events_url":"https://api.github.com/users/BobWhitelock/events{/privacy}","received_events_url":"https://api.github.com/users/BobWhitelock/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-01T12:17:59Z","updated_at":"2016-05-02T03:45:17Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rubygems/rubygems.org/pulls/1259","html_url":"https://github.com/rubygems/rubygems.org/pull/1259","diff_url":"https://github.com/rubygems/rubygems.org/pull/1259.diff","patch_url":"https://github.com/rubygems/rubygems.org/pull/1259.patch"},"body":"This is a fix for an issue mentioned in https://github.com/rubygems/rubygems.org/pull/1238.\r\n\r\nIf the stats page was visited while there were no downloads in the database, a `NoMethodError` would be thrown due to `@most_downloaded.first` being nil. This commit prevents this by checking it is available before accessing it.\r\n\r\nWhile this issue wouldn't occur in production it could in development after following the standard instructions for setting up a development environment in `CONTRIBUTING.md`."},"comment":{"url":"https://api.github.com/repos/rubygems/rubygems.org/issues/comments/216100495","html_url":"https://github.com/rubygems/rubygems.org/pull/1259#issuecomment-216100495","issue_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1259","id":216100495,"user":{"login":"dwradcliffe","id":118850,"avatar_url":"https://avatars.githubusercontent.com/u/118850?v=3","gravatar_id":"","url":"https://api.github.com/users/dwradcliffe","html_url":"https://github.com/dwradcliffe","followers_url":"https://api.github.com/users/dwradcliffe/followers","following_url":"https://api.github.com/users/dwradcliffe/following{/other_user}","gists_url":"https://api.github.com/users/dwradcliffe/gists{/gist_id}","starred_url":"https://api.github.com/users/dwradcliffe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwradcliffe/subscriptions","organizations_url":"https://api.github.com/users/dwradcliffe/orgs","repos_url":"https://api.github.com/users/dwradcliffe/repos","events_url":"https://api.github.com/users/dwradcliffe/events{/privacy}","received_events_url":"https://api.github.com/users/dwradcliffe/received_events","type":"User","site_admin":false},"created_at":"2016-05-02T03:45:17Z","updated_at":"2016-05-02T03:45:17Z","body":"Did you try this locally? I think this will still error when the view tries to use the `@most_downloaded_count` instance variable. The test here does not run view code so it doesn't catch this."}}