{"action":"created","comment":{"url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/comments/60789728","id":60789728,"diff_hunk":"@@ -146,8 +149,8 @@ def animal_energy_units(geom):\n         values = cursor.fetchone()  # Only one row since aggregate query\n         aeu = dict(zip(columns, values))\n \n-        livestock_aeu = round(sum(aeu[animal] for animal in LIVESTOCK))\n-        poultry_aeu = round(sum(aeu[animal] for animal in POULTRY))\n+        livestock_aeu = round(sum(aeu[animal] for animal in LIVESTOCK)) or 0\n+        poultry_aeu = round(sum(aeu[animal] for animal in POULTRY)) or 0","path":"src/mmw/apps/modeling/mapshed.py","position":17,"original_position":17,"commit_id":"96a9088e92196bae91e4b4502c689a6de4c31c7d","original_commit_id":"96a9088e92196bae91e4b4502c689a6de4c31c7d","user":{"login":"rajadain","id":1430060,"avatar_url":"https://avatars.githubusercontent.com/u/1430060?v=3","gravatar_id":"","url":"https://api.github.com/users/rajadain","html_url":"https://github.com/rajadain","followers_url":"https://api.github.com/users/rajadain/followers","following_url":"https://api.github.com/users/rajadain/following{/other_user}","gists_url":"https://api.github.com/users/rajadain/gists{/gist_id}","starred_url":"https://api.github.com/users/rajadain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajadain/subscriptions","organizations_url":"https://api.github.com/users/rajadain/orgs","repos_url":"https://api.github.com/users/rajadain/repos","events_url":"https://api.github.com/users/rajadain/events{/privacy}","received_events_url":"https://api.github.com/users/rajadain/received_events","type":"User","site_admin":false},"body":"Actually, the constants `LIVESTOCK` and `POULTRY` are composed of the column names returned from this query. They should **always** match. If they don't, then we _should_ raise an exception.\r\n\r\nHowever, if the value of one of those fields is `None`, that could interfere with the `sum`. I think moving the `0` inside, like this:\r\n\r\n```python\r\nlivestock_aeu = round(sum(aeu[animal] or 0 for animal in LIVESTOCK))\r\n```\r\n\r\nmight be better, so I will switch to that.","created_at":"2016-04-22T19:16:10Z","updated_at":"2016-04-22T19:16:10Z","html_url":"https://github.com/WikiWatershed/model-my-watershed/pull/1249#discussion_r60789728","pull_request_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/1249","_links":{"self":{"href":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/comments/60789728"},"html":{"href":"https://github.com/WikiWatershed/model-my-watershed/pull/1249#discussion_r60789728"},"pull_request":{"href":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/1249"}}},"pull_request":{"url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/1249","id":67554325,"html_url":"https://github.com/WikiWatershed/model-my-watershed/pull/1249","diff_url":"https://github.com/WikiWatershed/model-my-watershed/pull/1249.diff","patch_url":"https://github.com/WikiWatershed/model-my-watershed/pull/1249.patch","issue_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/issues/1249","number":1249,"state":"open","locked":false,"title":"Handle Empty Database Results for Small AoIs","user":{"login":"rajadain","id":1430060,"avatar_url":"https://avatars.githubusercontent.com/u/1430060?v=3","gravatar_id":"","url":"https://api.github.com/users/rajadain","html_url":"https://github.com/rajadain","followers_url":"https://api.github.com/users/rajadain/followers","following_url":"https://api.github.com/users/rajadain/following{/other_user}","gists_url":"https://api.github.com/users/rajadain/gists{/gist_id}","starred_url":"https://api.github.com/users/rajadain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajadain/subscriptions","organizations_url":"https://api.github.com/users/rajadain/orgs","repos_url":"https://api.github.com/users/rajadain/repos","events_url":"https://api.github.com/users/rajadain/events{/privacy}","received_events_url":"https://api.github.com/users/rajadain/received_events","type":"User","site_admin":false},"body":"## Overview\r\n\r\nFor small areas of interest, not all datasets would return values. For example, there may not be any streams, or any point sources of discharge, within a small polygon. Our code now handles these cases by following these rules:\r\n\r\n * If no weather stations are found, then raise an exception, since\r\n   they are necessary for multiple calculations\r\n * For singleton values, return 0 if nothing is found\r\n * For arrays, return arrays of 0 if nothing is found\r\n\r\n## Testing Instructions\r\n\r\nUsing the 1 sq km stamp tool, draw an AoI somewhere in central Philadelphia, as shown below:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/1430060/14751273/14015950-0897-11e6-9a54-db19f3296aac.png)\r\n\r\nObserve network traffic in either the developer tools, or using `./scripts/debugcelery.sh`. There should be no failures in processing the job.\r\n\r\n```\r\n[2016-04-22 14:22:44,736: INFO/MainProcess] Task apps.modeling.tasks.start_gwlfe_job[064aeb88-f895-456d-b6aa-cc9d7df604a9] succeeded in 0.619642704s: '{\"NumPondSys\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], \"RetentNLake\": 0.12, \"n41k\": 391.0, \"n38\": 0,...\r\n```\r\n\r\n## Code Review Instructions\r\n\r\n * Comment on the style of defaulting chosen. Suggest better alternatives if possible.\r\n * Comment if there are any missing edge cases on query results\r\n\r\nConnects #1245","created_at":"2016-04-22T18:36:32Z","updated_at":"2016-04-22T19:16:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a571b53e14412353e346160b2c37c63fb28cb91a","assignee":{"login":"lewfish","id":1896461,"avatar_url":"https://avatars.githubusercontent.com/u/1896461?v=3","gravatar_id":"","url":"https://api.github.com/users/lewfish","html_url":"https://github.com/lewfish","followers_url":"https://api.github.com/users/lewfish/followers","following_url":"https://api.github.com/users/lewfish/following{/other_user}","gists_url":"https://api.github.com/users/lewfish/gists{/gist_id}","starred_url":"https://api.github.com/users/lewfish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lewfish/subscriptions","organizations_url":"https://api.github.com/users/lewfish/orgs","repos_url":"https://api.github.com/users/lewfish/repos","events_url":"https://api.github.com/users/lewfish/events{/privacy}","received_events_url":"https://api.github.com/users/lewfish/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/1249/commits","review_comments_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/1249/comments","review_comment_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/issues/1249/comments","statuses_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/statuses/96a9088e92196bae91e4b4502c689a6de4c31c7d","head":{"label":"rajadain:feature/db-null-handling","ref":"feature/db-null-handling","sha":"96a9088e92196bae91e4b4502c689a6de4c31c7d","user":{"login":"rajadain","id":1430060,"avatar_url":"https://avatars.githubusercontent.com/u/1430060?v=3","gravatar_id":"","url":"https://api.github.com/users/rajadain","html_url":"https://github.com/rajadain","followers_url":"https://api.github.com/users/rajadain/followers","following_url":"https://api.github.com/users/rajadain/following{/other_user}","gists_url":"https://api.github.com/users/rajadain/gists{/gist_id}","starred_url":"https://api.github.com/users/rajadain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajadain/subscriptions","organizations_url":"https://api.github.com/users/rajadain/orgs","repos_url":"https://api.github.com/users/rajadain/repos","events_url":"https://api.github.com/users/rajadain/events{/privacy}","received_events_url":"https://api.github.com/users/rajadain/received_events","type":"User","site_admin":false},"repo":{"id":36075102,"name":"model-my-watershed","full_name":"rajadain/model-my-watershed","owner":{"login":"rajadain","id":1430060,"avatar_url":"https://avatars.githubusercontent.com/u/1430060?v=3","gravatar_id":"","url":"https://api.github.com/users/rajadain","html_url":"https://github.com/rajadain","followers_url":"https://api.github.com/users/rajadain/followers","following_url":"https://api.github.com/users/rajadain/following{/other_user}","gists_url":"https://api.github.com/users/rajadain/gists{/gist_id}","starred_url":"https://api.github.com/users/rajadain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajadain/subscriptions","organizations_url":"https://api.github.com/users/rajadain/orgs","repos_url":"https://api.github.com/users/rajadain/repos","events_url":"https://api.github.com/users/rajadain/events{/privacy}","received_events_url":"https://api.github.com/users/rajadain/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rajadain/model-my-watershed","description":"The web application front end for Model My Watershed.","fork":true,"url":"https://api.github.com/repos/rajadain/model-my-watershed","forks_url":"https://api.github.com/repos/rajadain/model-my-watershed/forks","keys_url":"https://api.github.com/repos/rajadain/model-my-watershed/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rajadain/model-my-watershed/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rajadain/model-my-watershed/teams","hooks_url":"https://api.github.com/repos/rajadain/model-my-watershed/hooks","issue_events_url":"https://api.github.com/repos/rajadain/model-my-watershed/issues/events{/number}","events_url":"https://api.github.com/repos/rajadain/model-my-watershed/events","assignees_url":"https://api.github.com/repos/rajadain/model-my-watershed/assignees{/user}","branches_url":"https://api.github.com/repos/rajadain/model-my-watershed/branches{/branch}","tags_url":"https://api.github.com/repos/rajadain/model-my-watershed/tags","blobs_url":"https://api.github.com/repos/rajadain/model-my-watershed/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rajadain/model-my-watershed/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rajadain/model-my-watershed/git/refs{/sha}","trees_url":"https://api.github.com/repos/rajadain/model-my-watershed/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rajadain/model-my-watershed/statuses/{sha}","languages_url":"https://api.github.com/repos/rajadain/model-my-watershed/languages","stargazers_url":"https://api.github.com/repos/rajadain/model-my-watershed/stargazers","contributors_url":"https://api.github.com/repos/rajadain/model-my-watershed/contributors","subscribers_url":"https://api.github.com/repos/rajadain/model-my-watershed/subscribers","subscription_url":"https://api.github.com/repos/rajadain/model-my-watershed/subscription","commits_url":"https://api.github.com/repos/rajadain/model-my-watershed/commits{/sha}","git_commits_url":"https://api.github.com/repos/rajadain/model-my-watershed/git/commits{/sha}","comments_url":"https://api.github.com/repos/rajadain/model-my-watershed/comments{/number}","issue_comment_url":"https://api.github.com/repos/rajadain/model-my-watershed/issues/comments{/number}","contents_url":"https://api.github.com/repos/rajadain/model-my-watershed/contents/{+path}","compare_url":"https://api.github.com/repos/rajadain/model-my-watershed/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rajadain/model-my-watershed/merges","archive_url":"https://api.github.com/repos/rajadain/model-my-watershed/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rajadain/model-my-watershed/downloads","issues_url":"https://api.github.com/repos/rajadain/model-my-watershed/issues{/number}","pulls_url":"https://api.github.com/repos/rajadain/model-my-watershed/pulls{/number}","milestones_url":"https://api.github.com/repos/rajadain/model-my-watershed/milestones{/number}","notifications_url":"https://api.github.com/repos/rajadain/model-my-watershed/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rajadain/model-my-watershed/labels{/name}","releases_url":"https://api.github.com/repos/rajadain/model-my-watershed/releases{/id}","deployments_url":"https://api.github.com/repos/rajadain/model-my-watershed/deployments","created_at":"2015-05-22T13:58:22Z","updated_at":"2016-02-17T19:28:33Z","pushed_at":"2016-04-22T18:30:13Z","git_url":"git://github.com/rajadain/model-my-watershed.git","ssh_url":"git@github.com:rajadain/model-my-watershed.git","clone_url":"https://github.com/rajadain/model-my-watershed.git","svn_url":"https://github.com/rajadain/model-my-watershed","homepage":null,"size":17065,"stargazers_count":0,"watchers_count":0,"language":"HTML","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":"develop"}},"base":{"label":"WikiWatershed:develop","ref":"develop","sha":"dc22d204b37a25f5b9b9157ffd51859b27ed8f1b","user":{"login":"WikiWatershed","id":8520008,"avatar_url":"https://avatars.githubusercontent.com/u/8520008?v=3","gravatar_id":"","url":"https://api.github.com/users/WikiWatershed","html_url":"https://github.com/WikiWatershed","followers_url":"https://api.github.com/users/WikiWatershed/followers","following_url":"https://api.github.com/users/WikiWatershed/following{/other_user}","gists_url":"https://api.github.com/users/WikiWatershed/gists{/gist_id}","starred_url":"https://api.github.com/users/WikiWatershed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WikiWatershed/subscriptions","organizations_url":"https://api.github.com/users/WikiWatershed/orgs","repos_url":"https://api.github.com/users/WikiWatershed/repos","events_url":"https://api.github.com/users/WikiWatershed/events{/privacy}","received_events_url":"https://api.github.com/users/WikiWatershed/received_events","type":"Organization","site_admin":false},"repo":{"id":32742922,"name":"model-my-watershed","full_name":"WikiWatershed/model-my-watershed","owner":{"login":"WikiWatershed","id":8520008,"avatar_url":"https://avatars.githubusercontent.com/u/8520008?v=3","gravatar_id":"","url":"https://api.github.com/users/WikiWatershed","html_url":"https://github.com/WikiWatershed","followers_url":"https://api.github.com/users/WikiWatershed/followers","following_url":"https://api.github.com/users/WikiWatershed/following{/other_user}","gists_url":"https://api.github.com/users/WikiWatershed/gists{/gist_id}","starred_url":"https://api.github.com/users/WikiWatershed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WikiWatershed/subscriptions","organizations_url":"https://api.github.com/users/WikiWatershed/orgs","repos_url":"https://api.github.com/users/WikiWatershed/repos","events_url":"https://api.github.com/users/WikiWatershed/events{/privacy}","received_events_url":"https://api.github.com/users/WikiWatershed/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WikiWatershed/model-my-watershed","description":"The web application front end for Model My Watershed.","fork":false,"url":"https://api.github.com/repos/WikiWatershed/model-my-watershed","forks_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/forks","keys_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/teams","hooks_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/hooks","issue_events_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/issues/events{/number}","events_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/events","assignees_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/assignees{/user}","branches_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/branches{/branch}","tags_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/tags","blobs_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/git/refs{/sha}","trees_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/statuses/{sha}","languages_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/languages","stargazers_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/stargazers","contributors_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/contributors","subscribers_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/subscribers","subscription_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/subscription","commits_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/commits{/sha}","git_commits_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/git/commits{/sha}","comments_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/comments{/number}","issue_comment_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/issues/comments{/number}","contents_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/contents/{+path}","compare_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/merges","archive_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/downloads","issues_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/issues{/number}","pulls_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls{/number}","milestones_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/milestones{/number}","notifications_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/labels{/name}","releases_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/releases{/id}","deployments_url":"https://api.github.com/repos/WikiWatershed/model-my-watershed/deployments","created_at":"2015-03-23T16:02:55Z","updated_at":"2016-01-22T18:26:23Z","pushed_at":"2016-04-22T18:36:33Z","git_url":"git://github.com/WikiWatershed/model-my-watershed.git","ssh_url":"git@github.com:WikiWatershed/model-my-watershed.git","clone_url":"https://github.com/WikiWatershed/model-my-watershed.git","svn_url":"https://github.com/WikiWatershed/model-my-watershed","homepage":null,"size":17653,"stargazers_count":4,"watchers_count":4,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":147,"forks":16,"open_issues":147,"watchers":4,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/1249"},"html":{"href":"https://github.com/WikiWatershed/model-my-watershed/pull/1249"},"issue":{"href":"https://api.github.com/repos/WikiWatershed/model-my-watershed/issues/1249"},"comments":{"href":"https://api.github.com/repos/WikiWatershed/model-my-watershed/issues/1249/comments"},"review_comments":{"href":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/1249/comments"},"review_comment":{"href":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WikiWatershed/model-my-watershed/pulls/1249/commits"},"statuses":{"href":"https://api.github.com/repos/WikiWatershed/model-my-watershed/statuses/96a9088e92196bae91e4b4502c689a6de4c31c7d"}}}}