{"action":"closed","issue":{"url":"https://api.github.com/repos/joshsoftware/code-curiosity/issues/151","repository_url":"https://api.github.com/repos/joshsoftware/code-curiosity","labels_url":"https://api.github.com/repos/joshsoftware/code-curiosity/issues/151/labels{/name}","comments_url":"https://api.github.com/repos/joshsoftware/code-curiosity/issues/151/comments","events_url":"https://api.github.com/repos/joshsoftware/code-curiosity/issues/151/events","html_url":"https://github.com/joshsoftware/code-curiosity/issues/151","id":181964680,"number":151,"title":"User's points not updated if a debit type transaction is created.","user":{"login":"prasadsurase","id":562052,"avatar_url":"https://avatars.githubusercontent.com/u/562052?v=3","gravatar_id":"","url":"https://api.github.com/users/prasadsurase","html_url":"https://github.com/prasadsurase","followers_url":"https://api.github.com/users/prasadsurase/followers","following_url":"https://api.github.com/users/prasadsurase/following{/other_user}","gists_url":"https://api.github.com/users/prasadsurase/gists{/gist_id}","starred_url":"https://api.github.com/users/prasadsurase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prasadsurase/subscriptions","organizations_url":"https://api.github.com/users/prasadsurase/orgs","repos_url":"https://api.github.com/users/prasadsurase/repos","events_url":"https://api.github.com/users/prasadsurase/events{/privacy}","received_events_url":"https://api.github.com/users/prasadsurase/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-10T08:55:43Z","updated_at":"2016-10-25T05:56:58Z","closed_at":"2016-10-25T05:56:58Z","body":"If a negative(debit) transaction is created, the user points aren't updated. [Transaction#update_user_total_points](https://github.com/joshsoftware/code-curiosity/blob/master/app/models/transaction.rb#L42) is executed as a callback when a transaction is created but if the transaction is of debit type(say, redeem request), the users points aren't updated to reflect the updated points. The method only updates the user points if its a credit transaction.\r\n\r\nSince any points being credited/debited to an user are recorded in transactions, [User#total_points](https://github.com/joshsoftware/code-curiosity/blob/master/app/models/user.rb#L201) returns the current user points, maintaining the same in a field(points in User model) is duplication and error prone. IMO, we should only use the provided method to retrieve user's points and remove the field."}}
{"actor":{"display_login":"prasadsurase"}}