{"action":"created","comment":{"url":"https://api.github.com/repos/apache/cloudstack/pulls/comments/47481989","id":47481989,"diff_hunk":"@@ -186,7 +186,7 @@ public int compare(QuotaBalanceVO o1, QuotaBalanceVO o2) {\n         //check that there is at least one balance entry\n         for (Iterator<QuotaBalanceVO> it = quotaBalance.iterator(); it.hasNext();) {\n             QuotaBalanceVO entry = it.next();\n-            if (entry.getCreditsId() > 0) {\n+            if (entry.getCreditsId() == 0) {","path":"plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java","position":5,"original_position":5,"commit_id":"b9ff4abadecc44924b0f77ebd2c8cb2d4f9cc253","original_commit_id":"b9ff4abadecc44924b0f77ebd2c8cb2d4f9cc253","user":{"login":"agneya2001","id":6416480,"avatar_url":"https://avatars.githubusercontent.com/u/6416480?v=3","gravatar_id":"","url":"https://api.github.com/users/agneya2001","html_url":"https://github.com/agneya2001","followers_url":"https://api.github.com/users/agneya2001/followers","following_url":"https://api.github.com/users/agneya2001/following{/other_user}","gists_url":"https://api.github.com/users/agneya2001/gists{/gist_id}","starred_url":"https://api.github.com/users/agneya2001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agneya2001/subscriptions","organizations_url":"https://api.github.com/users/agneya2001/orgs","repos_url":"https://api.github.com/users/agneya2001/repos","events_url":"https://api.github.com/users/agneya2001/events{/privacy}","received_events_url":"https://api.github.com/users/agneya2001/received_events","type":"User","site_admin":false},"body":"@DaanHoogland good that you are probing the logic.\r\n\r\nIn a system where quota service has never run, there could be credit entries a admin may want to add some credit entries even before quota service has run. So at a point the db can have credit entries without any real balance entry. There could be a situation where there is a balance entry after several credit entries followed by another set of credit entries.\r\n\r\nWhen there is a balance entry it consolidates all the credit entries that happened before it.\r\n\r\nSo when calculating balance you need to add all the credit entries that happened after a balance entry while ignoring all the credit entries that happened before the first balance entry. You till need to show all the credit entries that happened in between for the balance statement.\r\n\r\nWhen marvin tests were run the db was clean with only one credit entry. This was a special case where you add all the credit entries to show the final balance but you still need to show this credit entry in the balance statement. If quota service has run once it makes a 0 balance entry as part of bootstrapping.\r\n\r\nentry.getCreditsId() == 0, looks for real balance entry. A credit id that is non-zero refers to a credit entry with id being the credit id.","created_at":"2015-12-14T10:35:03Z","updated_at":"2015-12-14T10:35:03Z","html_url":"https://github.com/apache/cloudstack/pull/1240#discussion_r47481989","pull_request_url":"https://api.github.com/repos/apache/cloudstack/pulls/1240","_links":{"self":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/comments/47481989"},"html":{"href":"https://github.com/apache/cloudstack/pull/1240#discussion_r47481989"},"pull_request":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/1240"}}},"pull_request":{"url":"https://api.github.com/repos/apache/cloudstack/pulls/1240","id":53529756,"html_url":"https://github.com/apache/cloudstack/pull/1240","diff_url":"https://github.com/apache/cloudstack/pull/1240.diff","patch_url":"https://github.com/apache/cloudstack/pull/1240.patch","issue_url":"https://api.github.com/repos/apache/cloudstack/issues/1240","number":1240,"state":"open","locked":false,"title":"CLOUDSTACK-9161: fix the quota marvin test","user":{"login":"agneya2001","id":6416480,"avatar_url":"https://avatars.githubusercontent.com/u/6416480?v=3","gravatar_id":"","url":"https://api.github.com/users/agneya2001","html_url":"https://github.com/agneya2001","followers_url":"https://api.github.com/users/agneya2001/followers","following_url":"https://api.github.com/users/agneya2001/following{/other_user}","gists_url":"https://api.github.com/users/agneya2001/gists{/gist_id}","starred_url":"https://api.github.com/users/agneya2001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agneya2001/subscriptions","organizations_url":"https://api.github.com/users/agneya2001/orgs","repos_url":"https://api.github.com/users/agneya2001/repos","events_url":"https://api.github.com/users/agneya2001/events{/privacy}","received_events_url":"https://api.github.com/users/agneya2001/received_events","type":"User","site_admin":false},"body":"  1. Create a dummy user, as existing user may already have stale quota\r\n  data\r\n  2. fix the tests to use the dummy user\r\n  3. a boundary condition was revealed and fixed for a new user where\r\n  quota service has never run and created bootstrap entries","created_at":"2015-12-14T06:46:19Z","updated_at":"2015-12-14T10:35:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"832887a92262d1b4f4874b3bec0be0f74b1aad5e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/cloudstack/pulls/1240/commits","review_comments_url":"https://api.github.com/repos/apache/cloudstack/pulls/1240/comments","review_comment_url":"https://api.github.com/repos/apache/cloudstack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/cloudstack/issues/1240/comments","statuses_url":"https://api.github.com/repos/apache/cloudstack/statuses/b9ff4abadecc44924b0f77ebd2c8cb2d4f9cc253","head":{"label":"shapeblue:master-9161","ref":"master-9161","sha":"b9ff4abadecc44924b0f77ebd2c8cb2d4f9cc253","user":{"login":"shapeblue","id":6001764,"avatar_url":"https://avatars.githubusercontent.com/u/6001764?v=3","gravatar_id":"","url":"https://api.github.com/users/shapeblue","html_url":"https://github.com/shapeblue","followers_url":"https://api.github.com/users/shapeblue/followers","following_url":"https://api.github.com/users/shapeblue/following{/other_user}","gists_url":"https://api.github.com/users/shapeblue/gists{/gist_id}","starred_url":"https://api.github.com/users/shapeblue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shapeblue/subscriptions","organizations_url":"https://api.github.com/users/shapeblue/orgs","repos_url":"https://api.github.com/users/shapeblue/repos","events_url":"https://api.github.com/users/shapeblue/events{/privacy}","received_events_url":"https://api.github.com/users/shapeblue/received_events","type":"Organization","site_admin":false},"repo":{"id":35481491,"name":"cloudstack","full_name":"shapeblue/cloudstack","owner":{"login":"shapeblue","id":6001764,"avatar_url":"https://avatars.githubusercontent.com/u/6001764?v=3","gravatar_id":"","url":"https://api.github.com/users/shapeblue","html_url":"https://github.com/shapeblue","followers_url":"https://api.github.com/users/shapeblue/followers","following_url":"https://api.github.com/users/shapeblue/following{/other_user}","gists_url":"https://api.github.com/users/shapeblue/gists{/gist_id}","starred_url":"https://api.github.com/users/shapeblue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shapeblue/subscriptions","organizations_url":"https://api.github.com/users/shapeblue/orgs","repos_url":"https://api.github.com/users/shapeblue/repos","events_url":"https://api.github.com/users/shapeblue/events{/privacy}","received_events_url":"https://api.github.com/users/shapeblue/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shapeblue/cloudstack","description":"The upstream repository is at http://github.com/apache/cloudstack. This is ShapeBlue's support/patch branches and Apache CloudStack™ backup","fork":true,"url":"https://api.github.com/repos/shapeblue/cloudstack","forks_url":"https://api.github.com/repos/shapeblue/cloudstack/forks","keys_url":"https://api.github.com/repos/shapeblue/cloudstack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shapeblue/cloudstack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shapeblue/cloudstack/teams","hooks_url":"https://api.github.com/repos/shapeblue/cloudstack/hooks","issue_events_url":"https://api.github.com/repos/shapeblue/cloudstack/issues/events{/number}","events_url":"https://api.github.com/repos/shapeblue/cloudstack/events","assignees_url":"https://api.github.com/repos/shapeblue/cloudstack/assignees{/user}","branches_url":"https://api.github.com/repos/shapeblue/cloudstack/branches{/branch}","tags_url":"https://api.github.com/repos/shapeblue/cloudstack/tags","blobs_url":"https://api.github.com/repos/shapeblue/cloudstack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shapeblue/cloudstack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shapeblue/cloudstack/git/refs{/sha}","trees_url":"https://api.github.com/repos/shapeblue/cloudstack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shapeblue/cloudstack/statuses/{sha}","languages_url":"https://api.github.com/repos/shapeblue/cloudstack/languages","stargazers_url":"https://api.github.com/repos/shapeblue/cloudstack/stargazers","contributors_url":"https://api.github.com/repos/shapeblue/cloudstack/contributors","subscribers_url":"https://api.github.com/repos/shapeblue/cloudstack/subscribers","subscription_url":"https://api.github.com/repos/shapeblue/cloudstack/subscription","commits_url":"https://api.github.com/repos/shapeblue/cloudstack/commits{/sha}","git_commits_url":"https://api.github.com/repos/shapeblue/cloudstack/git/commits{/sha}","comments_url":"https://api.github.com/repos/shapeblue/cloudstack/comments{/number}","issue_comment_url":"https://api.github.com/repos/shapeblue/cloudstack/issues/comments{/number}","contents_url":"https://api.github.com/repos/shapeblue/cloudstack/contents/{+path}","compare_url":"https://api.github.com/repos/shapeblue/cloudstack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shapeblue/cloudstack/merges","archive_url":"https://api.github.com/repos/shapeblue/cloudstack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shapeblue/cloudstack/downloads","issues_url":"https://api.github.com/repos/shapeblue/cloudstack/issues{/number}","pulls_url":"https://api.github.com/repos/shapeblue/cloudstack/pulls{/number}","milestones_url":"https://api.github.com/repos/shapeblue/cloudstack/milestones{/number}","notifications_url":"https://api.github.com/repos/shapeblue/cloudstack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shapeblue/cloudstack/labels{/name}","releases_url":"https://api.github.com/repos/shapeblue/cloudstack/releases{/id}","created_at":"2015-05-12T10:22:21Z","updated_at":"2015-05-12T10:27:05Z","pushed_at":"2015-12-14T08:20:47Z","git_url":"git://github.com/shapeblue/cloudstack.git","ssh_url":"git@github.com:shapeblue/cloudstack.git","clone_url":"https://github.com/shapeblue/cloudstack.git","svn_url":"https://github.com/shapeblue/cloudstack","homepage":"http://shapeblue.com/packages","size":500807,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"7c83e1b2402db9e359fb086b158d65c25309a70e","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":9759448,"name":"cloudstack","full_name":"apache/cloudstack","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/cloudstack","description":"Mirror of Apache Cloudstack","fork":false,"url":"https://api.github.com/repos/apache/cloudstack","forks_url":"https://api.github.com/repos/apache/cloudstack/forks","keys_url":"https://api.github.com/repos/apache/cloudstack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/cloudstack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/cloudstack/teams","hooks_url":"https://api.github.com/repos/apache/cloudstack/hooks","issue_events_url":"https://api.github.com/repos/apache/cloudstack/issues/events{/number}","events_url":"https://api.github.com/repos/apache/cloudstack/events","assignees_url":"https://api.github.com/repos/apache/cloudstack/assignees{/user}","branches_url":"https://api.github.com/repos/apache/cloudstack/branches{/branch}","tags_url":"https://api.github.com/repos/apache/cloudstack/tags","blobs_url":"https://api.github.com/repos/apache/cloudstack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/cloudstack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/cloudstack/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/cloudstack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/cloudstack/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/cloudstack/languages","stargazers_url":"https://api.github.com/repos/apache/cloudstack/stargazers","contributors_url":"https://api.github.com/repos/apache/cloudstack/contributors","subscribers_url":"https://api.github.com/repos/apache/cloudstack/subscribers","subscription_url":"https://api.github.com/repos/apache/cloudstack/subscription","commits_url":"https://api.github.com/repos/apache/cloudstack/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/cloudstack/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/cloudstack/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/cloudstack/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/cloudstack/contents/{+path}","compare_url":"https://api.github.com/repos/apache/cloudstack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/cloudstack/merges","archive_url":"https://api.github.com/repos/apache/cloudstack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/cloudstack/downloads","issues_url":"https://api.github.com/repos/apache/cloudstack/issues{/number}","pulls_url":"https://api.github.com/repos/apache/cloudstack/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/cloudstack/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/cloudstack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/cloudstack/labels{/name}","releases_url":"https://api.github.com/repos/apache/cloudstack/releases{/id}","created_at":"2013-04-29T22:27:12Z","updated_at":"2015-12-11T12:16:06Z","pushed_at":"2015-12-14T10:20:39Z","git_url":"git://github.com/apache/cloudstack.git","ssh_url":"git@github.com:apache/cloudstack.git","clone_url":"https://github.com/apache/cloudstack.git","svn_url":"https://github.com/apache/cloudstack","homepage":null,"size":508467,"stargazers_count":325,"watchers_count":325,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":418,"mirror_url":"git://git.apache.org/cloudstack.git","open_issues_count":143,"forks":418,"open_issues":143,"watchers":325,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/1240"},"html":{"href":"https://github.com/apache/cloudstack/pull/1240"},"issue":{"href":"https://api.github.com/repos/apache/cloudstack/issues/1240"},"comments":{"href":"https://api.github.com/repos/apache/cloudstack/issues/1240/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/1240/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/1240/commits"},"statuses":{"href":"https://api.github.com/repos/apache/cloudstack/statuses/b9ff4abadecc44924b0f77ebd2c8cb2d4f9cc253"}}}}