{"action":"created","comment":{"url":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/comments/60812880","id":60812880,"diff_hunk":"@@ -13,6 +13,9 @@ class UserFitbit(models.Model):\n     access_token = models.TextField()\n     auth_secret = models.TextField()\n     refresh_token = models.TextField()\n+    # We will store the timestamp float number as it comes from Fitbit here\n+    expires_at = models.FloatField()\n+    timezone = models.CharField(max_length=128)","path":"fitapp/models.py","position":6,"original_position":6,"commit_id":"802d7a026a97b1333ee236525fc12b15d0bab7ad","original_commit_id":"802d7a026a97b1333ee236525fc12b15d0bab7ad","user":{"login":"brad","id":1614,"avatar_url":"https://avatars.githubusercontent.com/u/1614?v=3","gravatar_id":"","url":"https://api.github.com/users/brad","html_url":"https://github.com/brad","followers_url":"https://api.github.com/users/brad/followers","following_url":"https://api.github.com/users/brad/following{/other_user}","gists_url":"https://api.github.com/users/brad/gists{/gist_id}","starred_url":"https://api.github.com/users/brad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brad/subscriptions","organizations_url":"https://api.github.com/users/brad/orgs","repos_url":"https://api.github.com/users/brad/repos","events_url":"https://api.github.com/users/brad/events{/privacy}","received_events_url":"https://api.github.com/users/brad/received_events","type":"User","site_admin":false},"body":"@percyperez When I ran `makemigrations` it asked for a default and I specifie `UTC`","created_at":"2016-04-22T22:47:47Z","updated_at":"2016-04-22T22:47:47Z","html_url":"https://github.com/orcasgit/django-fitbit/pull/32#discussion_r60812880","pull_request_url":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/32","_links":{"self":{"href":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/comments/60812880"},"html":{"href":"https://github.com/orcasgit/django-fitbit/pull/32#discussion_r60812880"},"pull_request":{"href":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/32","id":67580329,"html_url":"https://github.com/orcasgit/django-fitbit/pull/32","diff_url":"https://github.com/orcasgit/django-fitbit/pull/32.diff","patch_url":"https://github.com/orcasgit/django-fitbit/pull/32.patch","issue_url":"https://api.github.com/repos/orcasgit/django-fitbit/issues/32","number":32,"state":"open","locked":false,"title":"Safe refresh","user":{"login":"brad","id":1614,"avatar_url":"https://avatars.githubusercontent.com/u/1614?v=3","gravatar_id":"","url":"https://api.github.com/users/brad","html_url":"https://github.com/brad","followers_url":"https://api.github.com/users/brad/followers","following_url":"https://api.github.com/users/brad/following{/other_user}","gists_url":"https://api.github.com/users/brad/gists{/gist_id}","starred_url":"https://api.github.com/users/brad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brad/subscriptions","organizations_url":"https://api.github.com/users/brad/orgs","repos_url":"https://api.github.com/users/brad/repos","events_url":"https://api.github.com/users/brad/events{/privacy}","received_events_url":"https://api.github.com/users/brad/received_events","type":"User","site_admin":false},"body":"@orcasgit/orcas-developers This has turned out to be a bit of a refactor, but I think refreshing tokens works better now. The changes:\r\n- New `expires_at` and `timezone` fields\r\n- More careful updating of saved tokens when refreshed. We check that the new expires_at is greater than the old and that the expires_at time is greater than now.\r\n- Added the `transaction.atomic()` decorator to the `get_fitbit_data` method.\r\n- more/better error handling for celery tasks. I think it's set up now so that every call to the API handles rate limit exceptions gracefully\r\n- Use timezone from the `UserFitbit` object rather than dealing with the session\r\n- PEP8 updates","created_at":"2016-04-22T22:14:47Z","updated_at":"2016-04-22T22:47:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bae7aaac2ee827fcc497138a6b12f0141ebfeb25","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/32/commits","review_comments_url":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/32/comments","review_comment_url":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/orcasgit/django-fitbit/issues/32/comments","statuses_url":"https://api.github.com/repos/orcasgit/django-fitbit/statuses/802d7a026a97b1333ee236525fc12b15d0bab7ad","head":{"label":"orcasgit:safe-refresh","ref":"safe-refresh","sha":"802d7a026a97b1333ee236525fc12b15d0bab7ad","user":{"login":"orcasgit","id":9833,"avatar_url":"https://avatars.githubusercontent.com/u/9833?v=3","gravatar_id":"","url":"https://api.github.com/users/orcasgit","html_url":"https://github.com/orcasgit","followers_url":"https://api.github.com/users/orcasgit/followers","following_url":"https://api.github.com/users/orcasgit/following{/other_user}","gists_url":"https://api.github.com/users/orcasgit/gists{/gist_id}","starred_url":"https://api.github.com/users/orcasgit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orcasgit/subscriptions","organizations_url":"https://api.github.com/users/orcasgit/orgs","repos_url":"https://api.github.com/users/orcasgit/repos","events_url":"https://api.github.com/users/orcasgit/events{/privacy}","received_events_url":"https://api.github.com/users/orcasgit/received_events","type":"Organization","site_admin":false},"repo":{"id":4838979,"name":"django-fitbit","full_name":"orcasgit/django-fitbit","owner":{"login":"orcasgit","id":9833,"avatar_url":"https://avatars.githubusercontent.com/u/9833?v=3","gravatar_id":"","url":"https://api.github.com/users/orcasgit","html_url":"https://github.com/orcasgit","followers_url":"https://api.github.com/users/orcasgit/followers","following_url":"https://api.github.com/users/orcasgit/following{/other_user}","gists_url":"https://api.github.com/users/orcasgit/gists{/gist_id}","starred_url":"https://api.github.com/users/orcasgit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orcasgit/subscriptions","organizations_url":"https://api.github.com/users/orcasgit/orgs","repos_url":"https://api.github.com/users/orcasgit/repos","events_url":"https://api.github.com/users/orcasgit/events{/privacy}","received_events_url":"https://api.github.com/users/orcasgit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/orcasgit/django-fitbit","description":"","fork":false,"url":"https://api.github.com/repos/orcasgit/django-fitbit","forks_url":"https://api.github.com/repos/orcasgit/django-fitbit/forks","keys_url":"https://api.github.com/repos/orcasgit/django-fitbit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/orcasgit/django-fitbit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/orcasgit/django-fitbit/teams","hooks_url":"https://api.github.com/repos/orcasgit/django-fitbit/hooks","issue_events_url":"https://api.github.com/repos/orcasgit/django-fitbit/issues/events{/number}","events_url":"https://api.github.com/repos/orcasgit/django-fitbit/events","assignees_url":"https://api.github.com/repos/orcasgit/django-fitbit/assignees{/user}","branches_url":"https://api.github.com/repos/orcasgit/django-fitbit/branches{/branch}","tags_url":"https://api.github.com/repos/orcasgit/django-fitbit/tags","blobs_url":"https://api.github.com/repos/orcasgit/django-fitbit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/orcasgit/django-fitbit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/orcasgit/django-fitbit/git/refs{/sha}","trees_url":"https://api.github.com/repos/orcasgit/django-fitbit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/orcasgit/django-fitbit/statuses/{sha}","languages_url":"https://api.github.com/repos/orcasgit/django-fitbit/languages","stargazers_url":"https://api.github.com/repos/orcasgit/django-fitbit/stargazers","contributors_url":"https://api.github.com/repos/orcasgit/django-fitbit/contributors","subscribers_url":"https://api.github.com/repos/orcasgit/django-fitbit/subscribers","subscription_url":"https://api.github.com/repos/orcasgit/django-fitbit/subscription","commits_url":"https://api.github.com/repos/orcasgit/django-fitbit/commits{/sha}","git_commits_url":"https://api.github.com/repos/orcasgit/django-fitbit/git/commits{/sha}","comments_url":"https://api.github.com/repos/orcasgit/django-fitbit/comments{/number}","issue_comment_url":"https://api.github.com/repos/orcasgit/django-fitbit/issues/comments{/number}","contents_url":"https://api.github.com/repos/orcasgit/django-fitbit/contents/{+path}","compare_url":"https://api.github.com/repos/orcasgit/django-fitbit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/orcasgit/django-fitbit/merges","archive_url":"https://api.github.com/repos/orcasgit/django-fitbit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/orcasgit/django-fitbit/downloads","issues_url":"https://api.github.com/repos/orcasgit/django-fitbit/issues{/number}","pulls_url":"https://api.github.com/repos/orcasgit/django-fitbit/pulls{/number}","milestones_url":"https://api.github.com/repos/orcasgit/django-fitbit/milestones{/number}","notifications_url":"https://api.github.com/repos/orcasgit/django-fitbit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/orcasgit/django-fitbit/labels{/name}","releases_url":"https://api.github.com/repos/orcasgit/django-fitbit/releases{/id}","deployments_url":"https://api.github.com/repos/orcasgit/django-fitbit/deployments","created_at":"2012-06-30T01:41:02Z","updated_at":"2016-04-22T20:07:02Z","pushed_at":"2016-04-22T22:14:48Z","git_url":"git://github.com/orcasgit/django-fitbit.git","ssh_url":"git@github.com:orcasgit/django-fitbit.git","clone_url":"https://github.com/orcasgit/django-fitbit.git","svn_url":"https://github.com/orcasgit/django-fitbit","homepage":null,"size":243,"stargazers_count":10,"watchers_count":10,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":4,"forks":15,"open_issues":4,"watchers":10,"default_branch":"master"}},"base":{"label":"orcasgit:master","ref":"master","sha":"ae6b5244a0069b067ef29e86eff18a45354072f1","user":{"login":"orcasgit","id":9833,"avatar_url":"https://avatars.githubusercontent.com/u/9833?v=3","gravatar_id":"","url":"https://api.github.com/users/orcasgit","html_url":"https://github.com/orcasgit","followers_url":"https://api.github.com/users/orcasgit/followers","following_url":"https://api.github.com/users/orcasgit/following{/other_user}","gists_url":"https://api.github.com/users/orcasgit/gists{/gist_id}","starred_url":"https://api.github.com/users/orcasgit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orcasgit/subscriptions","organizations_url":"https://api.github.com/users/orcasgit/orgs","repos_url":"https://api.github.com/users/orcasgit/repos","events_url":"https://api.github.com/users/orcasgit/events{/privacy}","received_events_url":"https://api.github.com/users/orcasgit/received_events","type":"Organization","site_admin":false},"repo":{"id":4838979,"name":"django-fitbit","full_name":"orcasgit/django-fitbit","owner":{"login":"orcasgit","id":9833,"avatar_url":"https://avatars.githubusercontent.com/u/9833?v=3","gravatar_id":"","url":"https://api.github.com/users/orcasgit","html_url":"https://github.com/orcasgit","followers_url":"https://api.github.com/users/orcasgit/followers","following_url":"https://api.github.com/users/orcasgit/following{/other_user}","gists_url":"https://api.github.com/users/orcasgit/gists{/gist_id}","starred_url":"https://api.github.com/users/orcasgit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orcasgit/subscriptions","organizations_url":"https://api.github.com/users/orcasgit/orgs","repos_url":"https://api.github.com/users/orcasgit/repos","events_url":"https://api.github.com/users/orcasgit/events{/privacy}","received_events_url":"https://api.github.com/users/orcasgit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/orcasgit/django-fitbit","description":"","fork":false,"url":"https://api.github.com/repos/orcasgit/django-fitbit","forks_url":"https://api.github.com/repos/orcasgit/django-fitbit/forks","keys_url":"https://api.github.com/repos/orcasgit/django-fitbit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/orcasgit/django-fitbit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/orcasgit/django-fitbit/teams","hooks_url":"https://api.github.com/repos/orcasgit/django-fitbit/hooks","issue_events_url":"https://api.github.com/repos/orcasgit/django-fitbit/issues/events{/number}","events_url":"https://api.github.com/repos/orcasgit/django-fitbit/events","assignees_url":"https://api.github.com/repos/orcasgit/django-fitbit/assignees{/user}","branches_url":"https://api.github.com/repos/orcasgit/django-fitbit/branches{/branch}","tags_url":"https://api.github.com/repos/orcasgit/django-fitbit/tags","blobs_url":"https://api.github.com/repos/orcasgit/django-fitbit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/orcasgit/django-fitbit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/orcasgit/django-fitbit/git/refs{/sha}","trees_url":"https://api.github.com/repos/orcasgit/django-fitbit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/orcasgit/django-fitbit/statuses/{sha}","languages_url":"https://api.github.com/repos/orcasgit/django-fitbit/languages","stargazers_url":"https://api.github.com/repos/orcasgit/django-fitbit/stargazers","contributors_url":"https://api.github.com/repos/orcasgit/django-fitbit/contributors","subscribers_url":"https://api.github.com/repos/orcasgit/django-fitbit/subscribers","subscription_url":"https://api.github.com/repos/orcasgit/django-fitbit/subscription","commits_url":"https://api.github.com/repos/orcasgit/django-fitbit/commits{/sha}","git_commits_url":"https://api.github.com/repos/orcasgit/django-fitbit/git/commits{/sha}","comments_url":"https://api.github.com/repos/orcasgit/django-fitbit/comments{/number}","issue_comment_url":"https://api.github.com/repos/orcasgit/django-fitbit/issues/comments{/number}","contents_url":"https://api.github.com/repos/orcasgit/django-fitbit/contents/{+path}","compare_url":"https://api.github.com/repos/orcasgit/django-fitbit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/orcasgit/django-fitbit/merges","archive_url":"https://api.github.com/repos/orcasgit/django-fitbit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/orcasgit/django-fitbit/downloads","issues_url":"https://api.github.com/repos/orcasgit/django-fitbit/issues{/number}","pulls_url":"https://api.github.com/repos/orcasgit/django-fitbit/pulls{/number}","milestones_url":"https://api.github.com/repos/orcasgit/django-fitbit/milestones{/number}","notifications_url":"https://api.github.com/repos/orcasgit/django-fitbit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/orcasgit/django-fitbit/labels{/name}","releases_url":"https://api.github.com/repos/orcasgit/django-fitbit/releases{/id}","deployments_url":"https://api.github.com/repos/orcasgit/django-fitbit/deployments","created_at":"2012-06-30T01:41:02Z","updated_at":"2016-04-22T20:07:02Z","pushed_at":"2016-04-22T22:14:48Z","git_url":"git://github.com/orcasgit/django-fitbit.git","ssh_url":"git@github.com:orcasgit/django-fitbit.git","clone_url":"https://github.com/orcasgit/django-fitbit.git","svn_url":"https://github.com/orcasgit/django-fitbit","homepage":null,"size":243,"stargazers_count":10,"watchers_count":10,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":4,"forks":15,"open_issues":4,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/32"},"html":{"href":"https://github.com/orcasgit/django-fitbit/pull/32"},"issue":{"href":"https://api.github.com/repos/orcasgit/django-fitbit/issues/32"},"comments":{"href":"https://api.github.com/repos/orcasgit/django-fitbit/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/orcasgit/django-fitbit/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/orcasgit/django-fitbit/statuses/802d7a026a97b1333ee236525fc12b15d0bab7ad"}}}}