{"action":"opened","number":26,"pull_request":{"url":"https://api.github.com/repos/zendesk/prop/pulls/26","id":85607125,"html_url":"https://github.com/zendesk/prop/pull/26","diff_url":"https://github.com/zendesk/prop/pull/26.diff","patch_url":"https://github.com/zendesk/prop/pull/26.patch","issue_url":"https://api.github.com/repos/zendesk/prop/issues/26","number":26,"state":"open","locked":false,"title":"use decrement to avoid float underflow","user":{"login":"zenhao","id":8106995,"avatar_url":"https://avatars.githubusercontent.com/u/8106995?v=3","gravatar_id":"","url":"https://api.github.com/users/zenhao","html_url":"https://github.com/zenhao","followers_url":"https://api.github.com/users/zenhao/followers","following_url":"https://api.github.com/users/zenhao/following{/other_user}","gists_url":"https://api.github.com/users/zenhao/gists{/gist_id}","starred_url":"https://api.github.com/users/zenhao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenhao/subscriptions","organizations_url":"https://api.github.com/users/zenhao/orgs","repos_url":"https://api.github.com/users/zenhao/repos","events_url":"https://api.github.com/users/zenhao/events{/privacy}","received_events_url":"https://api.github.com/users/zenhao/received_events","type":"User","site_admin":false},"body":"### Description\r\nIssue `1 - 1 = 4294967296`? We should use decrement not increment by `-1`.\r\n\r\n```\r\nzendesk(dev)> Prop.throttle(:account_creations, 'key')\r\n=> false\r\nzendesk(dev)> Prop.count(:account_creations, 'key')\r\n=> 1\r\nzendesk(dev)> Prop.throttle(:account_creations, 'key', {decrement: 1})\r\n=> true\r\nzendesk(dev)> Prop.count(:account_creations, 'key')\r\n=> 4294967296\r\n```\r\n\r\n### Changes made\r\n* We can not decrement below 0 for both strategies, because memcache can only decrement to `0` not negative numbers.\r\n\r\n  ```\r\nzendesk(dev)> Rails.cache.write(:test, 0, raw:true)\r\n=> true\r\nzendesk(dev)> Rails.cache.read(:test)\r\n=> \"0\"\r\nzendesk(dev)> Rails.cache.decrement(:test, 10)\r\n=> 0\r\nzendesk(dev)> Rails.cache.read(:test)\r\n=> \"0\"\r\n```\r\n\r\n@grosser ","created_at":"2016-09-16T17:04:38Z","updated_at":"2016-09-16T17:04:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b52a9888bc57e4c57ae0d7e9905de1528c0003b6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/zendesk/prop/pulls/26/commits","review_comments_url":"https://api.github.com/repos/zendesk/prop/pulls/26/comments","review_comment_url":"https://api.github.com/repos/zendesk/prop/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zendesk/prop/issues/26/comments","statuses_url":"https://api.github.com/repos/zendesk/prop/statuses/dd3669a6586b5cac7faa3cc0926a18e27bbcf972","head":{"label":"zendesk:hsun/fix_underflow","ref":"hsun/fix_underflow","sha":"dd3669a6586b5cac7faa3cc0926a18e27bbcf972","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":784411,"name":"prop","full_name":"zendesk/prop","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/prop","description":"Puts a cork in their requests","fork":false,"url":"https://api.github.com/repos/zendesk/prop","forks_url":"https://api.github.com/repos/zendesk/prop/forks","keys_url":"https://api.github.com/repos/zendesk/prop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/prop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/prop/teams","hooks_url":"https://api.github.com/repos/zendesk/prop/hooks","issue_events_url":"https://api.github.com/repos/zendesk/prop/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/prop/events","assignees_url":"https://api.github.com/repos/zendesk/prop/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/prop/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/prop/tags","blobs_url":"https://api.github.com/repos/zendesk/prop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/prop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/prop/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/prop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/prop/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/prop/languages","stargazers_url":"https://api.github.com/repos/zendesk/prop/stargazers","contributors_url":"https://api.github.com/repos/zendesk/prop/contributors","subscribers_url":"https://api.github.com/repos/zendesk/prop/subscribers","subscription_url":"https://api.github.com/repos/zendesk/prop/subscription","commits_url":"https://api.github.com/repos/zendesk/prop/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/prop/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/prop/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/prop/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/prop/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/prop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/prop/merges","archive_url":"https://api.github.com/repos/zendesk/prop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/prop/downloads","issues_url":"https://api.github.com/repos/zendesk/prop/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/prop/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/prop/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/prop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/prop/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/prop/releases{/id}","deployments_url":"https://api.github.com/repos/zendesk/prop/deployments","created_at":"2010-07-19T15:50:08Z","updated_at":"2016-08-24T23:28:15Z","pushed_at":"2016-09-16T17:04:38Z","git_url":"git://github.com/zendesk/prop.git","ssh_url":"git@github.com:zendesk/prop.git","clone_url":"https://github.com/zendesk/prop.git","svn_url":"https://github.com/zendesk/prop","homepage":null,"size":206,"stargazers_count":32,"watchers_count":32,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":32,"default_branch":"master"}},"base":{"label":"zendesk:master","ref":"master","sha":"80475a8b80cf0dfa72413edb3775da7ce5b2aa74","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":784411,"name":"prop","full_name":"zendesk/prop","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/prop","description":"Puts a cork in their requests","fork":false,"url":"https://api.github.com/repos/zendesk/prop","forks_url":"https://api.github.com/repos/zendesk/prop/forks","keys_url":"https://api.github.com/repos/zendesk/prop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/prop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/prop/teams","hooks_url":"https://api.github.com/repos/zendesk/prop/hooks","issue_events_url":"https://api.github.com/repos/zendesk/prop/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/prop/events","assignees_url":"https://api.github.com/repos/zendesk/prop/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/prop/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/prop/tags","blobs_url":"https://api.github.com/repos/zendesk/prop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/prop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/prop/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/prop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/prop/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/prop/languages","stargazers_url":"https://api.github.com/repos/zendesk/prop/stargazers","contributors_url":"https://api.github.com/repos/zendesk/prop/contributors","subscribers_url":"https://api.github.com/repos/zendesk/prop/subscribers","subscription_url":"https://api.github.com/repos/zendesk/prop/subscription","commits_url":"https://api.github.com/repos/zendesk/prop/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/prop/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/prop/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/prop/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/prop/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/prop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/prop/merges","archive_url":"https://api.github.com/repos/zendesk/prop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/prop/downloads","issues_url":"https://api.github.com/repos/zendesk/prop/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/prop/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/prop/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/prop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/prop/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/prop/releases{/id}","deployments_url":"https://api.github.com/repos/zendesk/prop/deployments","created_at":"2010-07-19T15:50:08Z","updated_at":"2016-08-24T23:28:15Z","pushed_at":"2016-09-16T17:04:38Z","git_url":"git://github.com/zendesk/prop.git","ssh_url":"git@github.com:zendesk/prop.git","clone_url":"https://github.com/zendesk/prop.git","svn_url":"https://github.com/zendesk/prop","homepage":null,"size":206,"stargazers_count":32,"watchers_count":32,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendesk/prop/pulls/26"},"html":{"href":"https://github.com/zendesk/prop/pull/26"},"issue":{"href":"https://api.github.com/repos/zendesk/prop/issues/26"},"comments":{"href":"https://api.github.com/repos/zendesk/prop/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/zendesk/prop/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/zendesk/prop/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zendesk/prop/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/zendesk/prop/statuses/dd3669a6586b5cac7faa3cc0926a18e27bbcf972"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":44,"deletions":25,"changed_files":5}}
{"actor":{"display_login":"zenhao"}}