{"action":"created","comment":{"url":"https://api.github.com/repos/CruGlobal/mpdx/pulls/comments/22598924","id":22598924,"diff_hunk":"@@ -154,18 +158,19 @@ angular.module('mpdxApp')\n                 };\n \n                 $scope.donationTotal = function(donations){\n-                    donations = _.flatten(donations, 'amount');\n-                    return donations.reduce(function(pv, cv) { return Number(pv) + Number(cv); }, 0);\n+                  var sum = 0;\n+                  angular.forEach(donations, function(d){\n+                    if(_.isNull(d.appeal_amount) || _.isEmpty(d.appeal_amount)){\n+                      sum += Number(d.amount);\n+                    }else{\n+                      sum += Number(d.appeal_amount);\n+                    }\n+                  });\n+                  return sum;\n                 };\n \n-                $scope.percentComplete = function(donations, total){\n-                    total = Number(total);\n-                    if(total === 0){\n-                        return 0;\n-                    }\n-                    donations = _.flatten(donations, 'amount');\n-                    var sum = donations.reduce(function(pv, cv) { return pv + Number(cv); }, 0);\n-                    return parseInt((sum / total) * 100);\n+                $scope.percentComplete = function(donationsTotal, goal){\n+                  return parseInt((donationsTotal / goal) * 100);","path":"app/assets/javascripts/angular/directives/appealsList.js","position":38,"original_position":38,"commit_id":"2e457a5d3dbb656fb152af571b4ae883a5cb2774","original_commit_id":"2e457a5d3dbb656fb152af571b4ae883a5cb2774","user":{"login":"soberstadt","id":1080613,"avatar_url":"https://avatars.githubusercontent.com/u/1080613?v=3","gravatar_id":"","url":"https://api.github.com/users/soberstadt","html_url":"https://github.com/soberstadt","followers_url":"https://api.github.com/users/soberstadt/followers","following_url":"https://api.github.com/users/soberstadt/following{/other_user}","gists_url":"https://api.github.com/users/soberstadt/gists{/gist_id}","starred_url":"https://api.github.com/users/soberstadt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soberstadt/subscriptions","organizations_url":"https://api.github.com/users/soberstadt/orgs","repos_url":"https://api.github.com/users/soberstadt/repos","events_url":"https://api.github.com/users/soberstadt/events{/privacy}","received_events_url":"https://api.github.com/users/soberstadt/received_events","type":"User","site_admin":false},"body":"Just because we saw a divide by 0 error yesterday, is there logic to make sure your goal can't be 0?","created_at":"2015-01-07T17:04:03Z","updated_at":"2015-01-07T17:04:03Z","html_url":"https://github.com/CruGlobal/mpdx/pull/227#discussion_r22598924","pull_request_url":"https://api.github.com/repos/CruGlobal/mpdx/pulls/227","_links":{"self":{"href":"https://api.github.com/repos/CruGlobal/mpdx/pulls/comments/22598924"},"html":{"href":"https://github.com/CruGlobal/mpdx/pull/227#discussion_r22598924"},"pull_request":{"href":"https://api.github.com/repos/CruGlobal/mpdx/pulls/227"}}},"pull_request":{"url":"https://api.github.com/repos/CruGlobal/mpdx/pulls/227","id":26967944,"html_url":"https://github.com/CruGlobal/mpdx/pull/227","diff_url":"https://github.com/CruGlobal/mpdx/pull/227.diff","patch_url":"https://github.com/CruGlobal/mpdx/pull/227.patch","issue_url":"https://api.github.com/repos/CruGlobal/mpdx/issues/227","number":227,"state":"open","locked":false,"title":"Add \"appeal amount\" to each donation","user":{"login":"adammeyer","id":4603906,"avatar_url":"https://avatars.githubusercontent.com/u/4603906?v=3","gravatar_id":"","url":"https://api.github.com/users/adammeyer","html_url":"https://github.com/adammeyer","followers_url":"https://api.github.com/users/adammeyer/followers","following_url":"https://api.github.com/users/adammeyer/following{/other_user}","gists_url":"https://api.github.com/users/adammeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/adammeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adammeyer/subscriptions","organizations_url":"https://api.github.com/users/adammeyer/orgs","repos_url":"https://api.github.com/users/adammeyer/repos","events_url":"https://api.github.com/users/adammeyer/events{/privacy}","received_events_url":"https://api.github.com/users/adammeyer/received_events","type":"User","site_admin":false},"body":"This allows a user to set part of a donation towards an appeal.","created_at":"2015-01-07T16:21:51Z","updated_at":"2015-01-07T17:04:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb0b8b4379aa75d81e2e4c2dd7cb7c4109a25667","assignee":{"login":"twinge","id":23668,"avatar_url":"https://avatars.githubusercontent.com/u/23668?v=3","gravatar_id":"","url":"https://api.github.com/users/twinge","html_url":"https://github.com/twinge","followers_url":"https://api.github.com/users/twinge/followers","following_url":"https://api.github.com/users/twinge/following{/other_user}","gists_url":"https://api.github.com/users/twinge/gists{/gist_id}","starred_url":"https://api.github.com/users/twinge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twinge/subscriptions","organizations_url":"https://api.github.com/users/twinge/orgs","repos_url":"https://api.github.com/users/twinge/repos","events_url":"https://api.github.com/users/twinge/events{/privacy}","received_events_url":"https://api.github.com/users/twinge/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/CruGlobal/mpdx/pulls/227/commits","review_comments_url":"https://api.github.com/repos/CruGlobal/mpdx/pulls/227/comments","review_comment_url":"https://api.github.com/repos/CruGlobal/mpdx/pulls/comments/{number}","comments_url":"https://api.github.com/repos/CruGlobal/mpdx/issues/227/comments","statuses_url":"https://api.github.com/repos/CruGlobal/mpdx/statuses/2e457a5d3dbb656fb152af571b4ae883a5cb2774","head":{"label":"CruGlobal:appealDonationAmounts","ref":"appealDonationAmounts","sha":"2e457a5d3dbb656fb152af571b4ae883a5cb2774","user":{"login":"CruGlobal","id":1785912,"avatar_url":"https://avatars.githubusercontent.com/u/1785912?v=3","gravatar_id":"","url":"https://api.github.com/users/CruGlobal","html_url":"https://github.com/CruGlobal","followers_url":"https://api.github.com/users/CruGlobal/followers","following_url":"https://api.github.com/users/CruGlobal/following{/other_user}","gists_url":"https://api.github.com/users/CruGlobal/gists{/gist_id}","starred_url":"https://api.github.com/users/CruGlobal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CruGlobal/subscriptions","organizations_url":"https://api.github.com/users/CruGlobal/orgs","repos_url":"https://api.github.com/users/CruGlobal/repos","events_url":"https://api.github.com/users/CruGlobal/events{/privacy}","received_events_url":"https://api.github.com/users/CruGlobal/received_events","type":"Organization","site_admin":false},"repo":{"id":4625882,"name":"mpdx","full_name":"CruGlobal/mpdx","owner":{"login":"CruGlobal","id":1785912,"avatar_url":"https://avatars.githubusercontent.com/u/1785912?v=3","gravatar_id":"","url":"https://api.github.com/users/CruGlobal","html_url":"https://github.com/CruGlobal","followers_url":"https://api.github.com/users/CruGlobal/followers","following_url":"https://api.github.com/users/CruGlobal/following{/other_user}","gists_url":"https://api.github.com/users/CruGlobal/gists{/gist_id}","starred_url":"https://api.github.com/users/CruGlobal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CruGlobal/subscriptions","organizations_url":"https://api.github.com/users/CruGlobal/orgs","repos_url":"https://api.github.com/users/CruGlobal/repos","events_url":"https://api.github.com/users/CruGlobal/events{/privacy}","received_events_url":"https://api.github.com/users/CruGlobal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CruGlobal/mpdx","description":"Web based tool to help missionaries stay in touch with ministry partners","fork":false,"url":"https://api.github.com/repos/CruGlobal/mpdx","forks_url":"https://api.github.com/repos/CruGlobal/mpdx/forks","keys_url":"https://api.github.com/repos/CruGlobal/mpdx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CruGlobal/mpdx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CruGlobal/mpdx/teams","hooks_url":"https://api.github.com/repos/CruGlobal/mpdx/hooks","issue_events_url":"https://api.github.com/repos/CruGlobal/mpdx/issues/events{/number}","events_url":"https://api.github.com/repos/CruGlobal/mpdx/events","assignees_url":"https://api.github.com/repos/CruGlobal/mpdx/assignees{/user}","branches_url":"https://api.github.com/repos/CruGlobal/mpdx/branches{/branch}","tags_url":"https://api.github.com/repos/CruGlobal/mpdx/tags","blobs_url":"https://api.github.com/repos/CruGlobal/mpdx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CruGlobal/mpdx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CruGlobal/mpdx/git/refs{/sha}","trees_url":"https://api.github.com/repos/CruGlobal/mpdx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CruGlobal/mpdx/statuses/{sha}","languages_url":"https://api.github.com/repos/CruGlobal/mpdx/languages","stargazers_url":"https://api.github.com/repos/CruGlobal/mpdx/stargazers","contributors_url":"https://api.github.com/repos/CruGlobal/mpdx/contributors","subscribers_url":"https://api.github.com/repos/CruGlobal/mpdx/subscribers","subscription_url":"https://api.github.com/repos/CruGlobal/mpdx/subscription","commits_url":"https://api.github.com/repos/CruGlobal/mpdx/commits{/sha}","git_commits_url":"https://api.github.com/repos/CruGlobal/mpdx/git/commits{/sha}","comments_url":"https://api.github.com/repos/CruGlobal/mpdx/comments{/number}","issue_comment_url":"https://api.github.com/repos/CruGlobal/mpdx/issues/comments/{number}","contents_url":"https://api.github.com/repos/CruGlobal/mpdx/contents/{+path}","compare_url":"https://api.github.com/repos/CruGlobal/mpdx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CruGlobal/mpdx/merges","archive_url":"https://api.github.com/repos/CruGlobal/mpdx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CruGlobal/mpdx/downloads","issues_url":"https://api.github.com/repos/CruGlobal/mpdx/issues{/number}","pulls_url":"https://api.github.com/repos/CruGlobal/mpdx/pulls{/number}","milestones_url":"https://api.github.com/repos/CruGlobal/mpdx/milestones{/number}","notifications_url":"https://api.github.com/repos/CruGlobal/mpdx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CruGlobal/mpdx/labels{/name}","releases_url":"https://api.github.com/repos/CruGlobal/mpdx/releases{/id}","created_at":"2012-06-11T14:26:20Z","updated_at":"2015-01-07T03:30:16Z","pushed_at":"2015-01-07T16:21:00Z","git_url":"git://github.com/CruGlobal/mpdx.git","ssh_url":"git@github.com:CruGlobal/mpdx.git","clone_url":"https://github.com/CruGlobal/mpdx.git","svn_url":"https://github.com/CruGlobal/mpdx","homepage":"https://mpdx.org","size":364829,"stargazers_count":8,"watchers_count":8,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":15,"forks":3,"open_issues":15,"watchers":8,"default_branch":"master"}},"base":{"label":"CruGlobal:master","ref":"master","sha":"e08303b6b9bcad7b87651f50cd9424dfd967f0b1","user":{"login":"CruGlobal","id":1785912,"avatar_url":"https://avatars.githubusercontent.com/u/1785912?v=3","gravatar_id":"","url":"https://api.github.com/users/CruGlobal","html_url":"https://github.com/CruGlobal","followers_url":"https://api.github.com/users/CruGlobal/followers","following_url":"https://api.github.com/users/CruGlobal/following{/other_user}","gists_url":"https://api.github.com/users/CruGlobal/gists{/gist_id}","starred_url":"https://api.github.com/users/CruGlobal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CruGlobal/subscriptions","organizations_url":"https://api.github.com/users/CruGlobal/orgs","repos_url":"https://api.github.com/users/CruGlobal/repos","events_url":"https://api.github.com/users/CruGlobal/events{/privacy}","received_events_url":"https://api.github.com/users/CruGlobal/received_events","type":"Organization","site_admin":false},"repo":{"id":4625882,"name":"mpdx","full_name":"CruGlobal/mpdx","owner":{"login":"CruGlobal","id":1785912,"avatar_url":"https://avatars.githubusercontent.com/u/1785912?v=3","gravatar_id":"","url":"https://api.github.com/users/CruGlobal","html_url":"https://github.com/CruGlobal","followers_url":"https://api.github.com/users/CruGlobal/followers","following_url":"https://api.github.com/users/CruGlobal/following{/other_user}","gists_url":"https://api.github.com/users/CruGlobal/gists{/gist_id}","starred_url":"https://api.github.com/users/CruGlobal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CruGlobal/subscriptions","organizations_url":"https://api.github.com/users/CruGlobal/orgs","repos_url":"https://api.github.com/users/CruGlobal/repos","events_url":"https://api.github.com/users/CruGlobal/events{/privacy}","received_events_url":"https://api.github.com/users/CruGlobal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CruGlobal/mpdx","description":"Web based tool to help missionaries stay in touch with ministry partners","fork":false,"url":"https://api.github.com/repos/CruGlobal/mpdx","forks_url":"https://api.github.com/repos/CruGlobal/mpdx/forks","keys_url":"https://api.github.com/repos/CruGlobal/mpdx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CruGlobal/mpdx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CruGlobal/mpdx/teams","hooks_url":"https://api.github.com/repos/CruGlobal/mpdx/hooks","issue_events_url":"https://api.github.com/repos/CruGlobal/mpdx/issues/events{/number}","events_url":"https://api.github.com/repos/CruGlobal/mpdx/events","assignees_url":"https://api.github.com/repos/CruGlobal/mpdx/assignees{/user}","branches_url":"https://api.github.com/repos/CruGlobal/mpdx/branches{/branch}","tags_url":"https://api.github.com/repos/CruGlobal/mpdx/tags","blobs_url":"https://api.github.com/repos/CruGlobal/mpdx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CruGlobal/mpdx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CruGlobal/mpdx/git/refs{/sha}","trees_url":"https://api.github.com/repos/CruGlobal/mpdx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CruGlobal/mpdx/statuses/{sha}","languages_url":"https://api.github.com/repos/CruGlobal/mpdx/languages","stargazers_url":"https://api.github.com/repos/CruGlobal/mpdx/stargazers","contributors_url":"https://api.github.com/repos/CruGlobal/mpdx/contributors","subscribers_url":"https://api.github.com/repos/CruGlobal/mpdx/subscribers","subscription_url":"https://api.github.com/repos/CruGlobal/mpdx/subscription","commits_url":"https://api.github.com/repos/CruGlobal/mpdx/commits{/sha}","git_commits_url":"https://api.github.com/repos/CruGlobal/mpdx/git/commits{/sha}","comments_url":"https://api.github.com/repos/CruGlobal/mpdx/comments{/number}","issue_comment_url":"https://api.github.com/repos/CruGlobal/mpdx/issues/comments/{number}","contents_url":"https://api.github.com/repos/CruGlobal/mpdx/contents/{+path}","compare_url":"https://api.github.com/repos/CruGlobal/mpdx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CruGlobal/mpdx/merges","archive_url":"https://api.github.com/repos/CruGlobal/mpdx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CruGlobal/mpdx/downloads","issues_url":"https://api.github.com/repos/CruGlobal/mpdx/issues{/number}","pulls_url":"https://api.github.com/repos/CruGlobal/mpdx/pulls{/number}","milestones_url":"https://api.github.com/repos/CruGlobal/mpdx/milestones{/number}","notifications_url":"https://api.github.com/repos/CruGlobal/mpdx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CruGlobal/mpdx/labels{/name}","releases_url":"https://api.github.com/repos/CruGlobal/mpdx/releases{/id}","created_at":"2012-06-11T14:26:20Z","updated_at":"2015-01-07T03:30:16Z","pushed_at":"2015-01-07T16:21:00Z","git_url":"git://github.com/CruGlobal/mpdx.git","ssh_url":"git@github.com:CruGlobal/mpdx.git","clone_url":"https://github.com/CruGlobal/mpdx.git","svn_url":"https://github.com/CruGlobal/mpdx","homepage":"https://mpdx.org","size":364829,"stargazers_count":8,"watchers_count":8,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":15,"forks":3,"open_issues":15,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CruGlobal/mpdx/pulls/227"},"html":{"href":"https://github.com/CruGlobal/mpdx/pull/227"},"issue":{"href":"https://api.github.com/repos/CruGlobal/mpdx/issues/227"},"comments":{"href":"https://api.github.com/repos/CruGlobal/mpdx/issues/227/comments"},"review_comments":{"href":"https://api.github.com/repos/CruGlobal/mpdx/pulls/227/comments"},"review_comment":{"href":"https://api.github.com/repos/CruGlobal/mpdx/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/CruGlobal/mpdx/pulls/227/commits"},"statuses":{"href":"https://api.github.com/repos/CruGlobal/mpdx/statuses/2e457a5d3dbb656fb152af571b4ae883a5cb2774"}}}}