{"action":"created","comment":{"url":"https://api.github.com/repos/freshBudgets/backend/pulls/comments/238921706","pull_request_review_id":181579847,"id":238921706,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODkyMTcwNg==","diff_hunk":"@@ -198,37 +199,55 @@ const getAll = function(req, res) {\n             });\n         }\n     });\n+};\n+\n+const getWeeklyTransactions = function(budgetId, userID) {\n+    return new Promise((resolve, reject) => {\n+        const thisSunday = moment().day(0).format('YYYY-MM-DD');\n+        const nextSunday = moment().day(7).format('YYYY-MM-DD');\n+        Transactions.find({budget_id: budgetId, user_id: userID, isDeleted: false, date: {$gte: thisSunday, $lte: nextSunday}}, function(err, transactions) {\n+            if (err) reject(err);    \n+            return resolve(transactions);\n+        });\n+    });\n+};\n+\n+async function getCurrentAmount(budgetID, userID) {\n+    return new Promise((resolve, reject) => {\n+        getWeeklyTransactions(budgetID, userID).then((transactions) => {\n+            let total = 0;\n+            for (let i = 0; i < transactions.length; i++) {\n+                total += transactions[i].amount;\n+            }\n+            resolve(total);\n+        });\n+    });\n }\n \n+async function testGetCurrentAmount(req, res) {","path":"routes/transactions.js","position":37,"original_position":37,"commit_id":"91fbbff7a9c644822ee0383680d5a99109f47bb7","original_commit_id":"91fbbff7a9c644822ee0383680d5a99109f47bb7","user":{"login":"colejoh","id":6447913,"node_id":"MDQ6VXNlcjY0NDc5MTM=","avatar_url":"https://avatars1.githubusercontent.com/u/6447913?v=4","gravatar_id":"","url":"https://api.github.com/users/colejoh","html_url":"https://github.com/colejoh","followers_url":"https://api.github.com/users/colejoh/followers","following_url":"https://api.github.com/users/colejoh/following{/other_user}","gists_url":"https://api.github.com/users/colejoh/gists{/gist_id}","starred_url":"https://api.github.com/users/colejoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colejoh/subscriptions","organizations_url":"https://api.github.com/users/colejoh/orgs","repos_url":"https://api.github.com/users/colejoh/repos","events_url":"https://api.github.com/users/colejoh/events{/privacy}","received_events_url":"https://api.github.com/users/colejoh/received_events","type":"User","site_admin":false},"body":"Take this bad boi out","created_at":"2018-12-05T03:32:52Z","updated_at":"2018-12-05T03:32:52Z","html_url":"https://github.com/freshBudgets/backend/pull/49#discussion_r238921706","pull_request_url":"https://api.github.com/repos/freshBudgets/backend/pulls/49","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/freshBudgets/backend/pulls/comments/238921706"},"html":{"href":"https://github.com/freshBudgets/backend/pull/49#discussion_r238921706"},"pull_request":{"href":"https://api.github.com/repos/freshBudgets/backend/pulls/49"}}},"pull_request":{"url":"https://api.github.com/repos/freshBudgets/backend/pulls/49","id":236035000,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM2MDM1MDAw","html_url":"https://github.com/freshBudgets/backend/pull/49","diff_url":"https://github.com/freshBudgets/backend/pull/49.diff","patch_url":"https://github.com/freshBudgets/backend/pull/49.patch","issue_url":"https://api.github.com/repos/freshBudgets/backend/issues/49","number":49,"state":"open","locked":false,"title":"calculate current amount based on transactions present in a budget. t…","user":{"login":"keeganirby","id":14003172,"node_id":"MDQ6VXNlcjE0MDAzMTcy","avatar_url":"https://avatars2.githubusercontent.com/u/14003172?v=4","gravatar_id":"","url":"https://api.github.com/users/keeganirby","html_url":"https://github.com/keeganirby","followers_url":"https://api.github.com/users/keeganirby/followers","following_url":"https://api.github.com/users/keeganirby/following{/other_user}","gists_url":"https://api.github.com/users/keeganirby/gists{/gist_id}","starred_url":"https://api.github.com/users/keeganirby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keeganirby/subscriptions","organizations_url":"https://api.github.com/users/keeganirby/orgs","repos_url":"https://api.github.com/users/keeganirby/repos","events_url":"https://api.github.com/users/keeganirby/events{/privacy}","received_events_url":"https://api.github.com/users/keeganirby/received_events","type":"User","site_admin":false},"body":"calculate current amount based on transactions present in a budget. transactions are queried on a weekly basis","created_at":"2018-12-05T03:29:03Z","updated_at":"2018-12-05T03:32:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e7d874e1064ead9028a0b183ec41a56789126dc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/freshBudgets/backend/pulls/49/commits","review_comments_url":"https://api.github.com/repos/freshBudgets/backend/pulls/49/comments","review_comment_url":"https://api.github.com/repos/freshBudgets/backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/freshBudgets/backend/issues/49/comments","statuses_url":"https://api.github.com/repos/freshBudgets/backend/statuses/91fbbff7a9c644822ee0383680d5a99109f47bb7","head":{"label":"freshBudgets:kirby-spicypr","ref":"kirby-spicypr","sha":"91fbbff7a9c644822ee0383680d5a99109f47bb7","user":{"login":"freshBudgets","id":42783075,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyNzgzMDc1","avatar_url":"https://avatars0.githubusercontent.com/u/42783075?v=4","gravatar_id":"","url":"https://api.github.com/users/freshBudgets","html_url":"https://github.com/freshBudgets","followers_url":"https://api.github.com/users/freshBudgets/followers","following_url":"https://api.github.com/users/freshBudgets/following{/other_user}","gists_url":"https://api.github.com/users/freshBudgets/gists{/gist_id}","starred_url":"https://api.github.com/users/freshBudgets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freshBudgets/subscriptions","organizations_url":"https://api.github.com/users/freshBudgets/orgs","repos_url":"https://api.github.com/users/freshBudgets/repos","events_url":"https://api.github.com/users/freshBudgets/events{/privacy}","received_events_url":"https://api.github.com/users/freshBudgets/received_events","type":"Organization","site_admin":false},"repo":{"id":146490749,"node_id":"MDEwOlJlcG9zaXRvcnkxNDY0OTA3NDk=","name":"backend","full_name":"freshBudgets/backend","private":false,"owner":{"login":"freshBudgets","id":42783075,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyNzgzMDc1","avatar_url":"https://avatars0.githubusercontent.com/u/42783075?v=4","gravatar_id":"","url":"https://api.github.com/users/freshBudgets","html_url":"https://github.com/freshBudgets","followers_url":"https://api.github.com/users/freshBudgets/followers","following_url":"https://api.github.com/users/freshBudgets/following{/other_user}","gists_url":"https://api.github.com/users/freshBudgets/gists{/gist_id}","starred_url":"https://api.github.com/users/freshBudgets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freshBudgets/subscriptions","organizations_url":"https://api.github.com/users/freshBudgets/orgs","repos_url":"https://api.github.com/users/freshBudgets/repos","events_url":"https://api.github.com/users/freshBudgets/events{/privacy}","received_events_url":"https://api.github.com/users/freshBudgets/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/freshBudgets/backend","description":"Budgeting webapp utilizing SMS to help track finances","fork":false,"url":"https://api.github.com/repos/freshBudgets/backend","forks_url":"https://api.github.com/repos/freshBudgets/backend/forks","keys_url":"https://api.github.com/repos/freshBudgets/backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freshBudgets/backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freshBudgets/backend/teams","hooks_url":"https://api.github.com/repos/freshBudgets/backend/hooks","issue_events_url":"https://api.github.com/repos/freshBudgets/backend/issues/events{/number}","events_url":"https://api.github.com/repos/freshBudgets/backend/events","assignees_url":"https://api.github.com/repos/freshBudgets/backend/assignees{/user}","branches_url":"https://api.github.com/repos/freshBudgets/backend/branches{/branch}","tags_url":"https://api.github.com/repos/freshBudgets/backend/tags","blobs_url":"https://api.github.com/repos/freshBudgets/backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freshBudgets/backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freshBudgets/backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/freshBudgets/backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freshBudgets/backend/statuses/{sha}","languages_url":"https://api.github.com/repos/freshBudgets/backend/languages","stargazers_url":"https://api.github.com/repos/freshBudgets/backend/stargazers","contributors_url":"https://api.github.com/repos/freshBudgets/backend/contributors","subscribers_url":"https://api.github.com/repos/freshBudgets/backend/subscribers","subscription_url":"https://api.github.com/repos/freshBudgets/backend/subscription","commits_url":"https://api.github.com/repos/freshBudgets/backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/freshBudgets/backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/freshBudgets/backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/freshBudgets/backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/freshBudgets/backend/contents/{+path}","compare_url":"https://api.github.com/repos/freshBudgets/backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freshBudgets/backend/merges","archive_url":"https://api.github.com/repos/freshBudgets/backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freshBudgets/backend/downloads","issues_url":"https://api.github.com/repos/freshBudgets/backend/issues{/number}","pulls_url":"https://api.github.com/repos/freshBudgets/backend/pulls{/number}","milestones_url":"https://api.github.com/repos/freshBudgets/backend/milestones{/number}","notifications_url":"https://api.github.com/repos/freshBudgets/backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freshBudgets/backend/labels{/name}","releases_url":"https://api.github.com/repos/freshBudgets/backend/releases{/id}","deployments_url":"https://api.github.com/repos/freshBudgets/backend/deployments","created_at":"2018-08-28T18:37:26Z","updated_at":"2018-12-05T03:07:48Z","pushed_at":"2018-12-05T03:31:26Z","git_url":"git://github.com/freshBudgets/backend.git","ssh_url":"git@github.com:freshBudgets/backend.git","clone_url":"https://github.com/freshBudgets/backend.git","svn_url":"https://github.com/freshBudgets/backend","homepage":"https://freshbudgets.com","size":202,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":1,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"freshBudgets:master","ref":"master","sha":"8c672050d34c763a7619c16eb7bc9584cafa38d5","user":{"login":"freshBudgets","id":42783075,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyNzgzMDc1","avatar_url":"https://avatars0.githubusercontent.com/u/42783075?v=4","gravatar_id":"","url":"https://api.github.com/users/freshBudgets","html_url":"https://github.com/freshBudgets","followers_url":"https://api.github.com/users/freshBudgets/followers","following_url":"https://api.github.com/users/freshBudgets/following{/other_user}","gists_url":"https://api.github.com/users/freshBudgets/gists{/gist_id}","starred_url":"https://api.github.com/users/freshBudgets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freshBudgets/subscriptions","organizations_url":"https://api.github.com/users/freshBudgets/orgs","repos_url":"https://api.github.com/users/freshBudgets/repos","events_url":"https://api.github.com/users/freshBudgets/events{/privacy}","received_events_url":"https://api.github.com/users/freshBudgets/received_events","type":"Organization","site_admin":false},"repo":{"id":146490749,"node_id":"MDEwOlJlcG9zaXRvcnkxNDY0OTA3NDk=","name":"backend","full_name":"freshBudgets/backend","private":false,"owner":{"login":"freshBudgets","id":42783075,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyNzgzMDc1","avatar_url":"https://avatars0.githubusercontent.com/u/42783075?v=4","gravatar_id":"","url":"https://api.github.com/users/freshBudgets","html_url":"https://github.com/freshBudgets","followers_url":"https://api.github.com/users/freshBudgets/followers","following_url":"https://api.github.com/users/freshBudgets/following{/other_user}","gists_url":"https://api.github.com/users/freshBudgets/gists{/gist_id}","starred_url":"https://api.github.com/users/freshBudgets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freshBudgets/subscriptions","organizations_url":"https://api.github.com/users/freshBudgets/orgs","repos_url":"https://api.github.com/users/freshBudgets/repos","events_url":"https://api.github.com/users/freshBudgets/events{/privacy}","received_events_url":"https://api.github.com/users/freshBudgets/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/freshBudgets/backend","description":"Budgeting webapp utilizing SMS to help track finances","fork":false,"url":"https://api.github.com/repos/freshBudgets/backend","forks_url":"https://api.github.com/repos/freshBudgets/backend/forks","keys_url":"https://api.github.com/repos/freshBudgets/backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freshBudgets/backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freshBudgets/backend/teams","hooks_url":"https://api.github.com/repos/freshBudgets/backend/hooks","issue_events_url":"https://api.github.com/repos/freshBudgets/backend/issues/events{/number}","events_url":"https://api.github.com/repos/freshBudgets/backend/events","assignees_url":"https://api.github.com/repos/freshBudgets/backend/assignees{/user}","branches_url":"https://api.github.com/repos/freshBudgets/backend/branches{/branch}","tags_url":"https://api.github.com/repos/freshBudgets/backend/tags","blobs_url":"https://api.github.com/repos/freshBudgets/backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freshBudgets/backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freshBudgets/backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/freshBudgets/backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freshBudgets/backend/statuses/{sha}","languages_url":"https://api.github.com/repos/freshBudgets/backend/languages","stargazers_url":"https://api.github.com/repos/freshBudgets/backend/stargazers","contributors_url":"https://api.github.com/repos/freshBudgets/backend/contributors","subscribers_url":"https://api.github.com/repos/freshBudgets/backend/subscribers","subscription_url":"https://api.github.com/repos/freshBudgets/backend/subscription","commits_url":"https://api.github.com/repos/freshBudgets/backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/freshBudgets/backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/freshBudgets/backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/freshBudgets/backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/freshBudgets/backend/contents/{+path}","compare_url":"https://api.github.com/repos/freshBudgets/backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freshBudgets/backend/merges","archive_url":"https://api.github.com/repos/freshBudgets/backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freshBudgets/backend/downloads","issues_url":"https://api.github.com/repos/freshBudgets/backend/issues{/number}","pulls_url":"https://api.github.com/repos/freshBudgets/backend/pulls{/number}","milestones_url":"https://api.github.com/repos/freshBudgets/backend/milestones{/number}","notifications_url":"https://api.github.com/repos/freshBudgets/backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freshBudgets/backend/labels{/name}","releases_url":"https://api.github.com/repos/freshBudgets/backend/releases{/id}","deployments_url":"https://api.github.com/repos/freshBudgets/backend/deployments","created_at":"2018-08-28T18:37:26Z","updated_at":"2018-12-05T03:07:48Z","pushed_at":"2018-12-05T03:31:26Z","git_url":"git://github.com/freshBudgets/backend.git","ssh_url":"git@github.com:freshBudgets/backend.git","clone_url":"https://github.com/freshBudgets/backend.git","svn_url":"https://github.com/freshBudgets/backend","homepage":"https://freshbudgets.com","size":202,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":1,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/freshBudgets/backend/pulls/49"},"html":{"href":"https://github.com/freshBudgets/backend/pull/49"},"issue":{"href":"https://api.github.com/repos/freshBudgets/backend/issues/49"},"comments":{"href":"https://api.github.com/repos/freshBudgets/backend/issues/49/comments"},"review_comments":{"href":"https://api.github.com/repos/freshBudgets/backend/pulls/49/comments"},"review_comment":{"href":"https://api.github.com/repos/freshBudgets/backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/freshBudgets/backend/pulls/49/commits"},"statuses":{"href":"https://api.github.com/repos/freshBudgets/backend/statuses/91fbbff7a9c644822ee0383680d5a99109f47bb7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"colejoh"}}