{"action":"created","comment":{"url":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/comments/39027382","id":39027382,"diff_hunk":"@@ -1,18 +1,41 @@\n class Review\n   include ActiveModel::Model\n   attr_accessor :card_id, :answer\n+  SPACE_INTERVALS = [12.hours,3.day,1.week,2.week,1.month]\n \n   def check_translation\n-    if answer.strip.mb_chars.downcase == original_text.strip.mb_chars.downcase\n-      card.update(review_date: new_review_date)\n-      true\n-    else\n-      false\n-    end\n+    update_card\n+    answer_correct?\n   end\n \n   def new_review_date\n-    Date.current + 3.day\n+    Time.current + SPACE_INTERVALS[card.review_count]\n+  end\n+\n+  def review_count\n+    @review_count ||= card.review_count + 1\n+  end\n+\n+  def failed_review_count\n+    @failed_review_count ||= (card.failed_review_count + 1)%3\n+  end\n+\n+  def answer_correct?\n+    @answer_correct ||= answer.strip.mb_chars.downcase == original_text.strip.mb_chars.downcase","path":"app/models/review.rb","position":31,"original_position":31,"commit_id":"97098d4bc914726e8b51ce56175f5f024460c134","original_commit_id":"97098d4bc914726e8b51ce56175f5f024460c134","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long. [95/80]","created_at":"2015-09-09T10:26:04Z","updated_at":"2015-09-09T10:26:04Z","html_url":"https://github.com/yuri-polessky/flashcards/pull/14#discussion_r39027382","pull_request_url":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/comments/39027382"},"html":{"href":"https://github.com/yuri-polessky/flashcards/pull/14#discussion_r39027382"},"pull_request":{"href":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/14","id":44533260,"html_url":"https://github.com/yuri-polessky/flashcards/pull/14","diff_url":"https://github.com/yuri-polessky/flashcards/pull/14.diff","patch_url":"https://github.com/yuri-polessky/flashcards/pull/14.patch","issue_url":"https://api.github.com/repos/yuri-polessky/flashcards/issues/14","number":14,"state":"open","locked":false,"title":"Implemented spaced repetition system","user":{"login":"yuri-polessky","id":9403076,"avatar_url":"https://avatars.githubusercontent.com/u/9403076?v=3","gravatar_id":"","url":"https://api.github.com/users/yuri-polessky","html_url":"https://github.com/yuri-polessky","followers_url":"https://api.github.com/users/yuri-polessky/followers","following_url":"https://api.github.com/users/yuri-polessky/following{/other_user}","gists_url":"https://api.github.com/users/yuri-polessky/gists{/gist_id}","starred_url":"https://api.github.com/users/yuri-polessky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuri-polessky/subscriptions","organizations_url":"https://api.github.com/users/yuri-polessky/orgs","repos_url":"https://api.github.com/users/yuri-polessky/repos","events_url":"https://api.github.com/users/yuri-polessky/events{/privacy}","received_events_url":"https://api.github.com/users/yuri-polessky/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-09T10:25:57Z","updated_at":"2015-09-09T10:26:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"585196bd9ba30850bd56ed26970a826e9ddbe0ce","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/14/commits","review_comments_url":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/14/comments","review_comment_url":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yuri-polessky/flashcards/issues/14/comments","statuses_url":"https://api.github.com/repos/yuri-polessky/flashcards/statuses/97098d4bc914726e8b51ce56175f5f024460c134","head":{"label":"yuri-polessky:thirteenth-task","ref":"thirteenth-task","sha":"97098d4bc914726e8b51ce56175f5f024460c134","user":{"login":"yuri-polessky","id":9403076,"avatar_url":"https://avatars.githubusercontent.com/u/9403076?v=3","gravatar_id":"","url":"https://api.github.com/users/yuri-polessky","html_url":"https://github.com/yuri-polessky","followers_url":"https://api.github.com/users/yuri-polessky/followers","following_url":"https://api.github.com/users/yuri-polessky/following{/other_user}","gists_url":"https://api.github.com/users/yuri-polessky/gists{/gist_id}","starred_url":"https://api.github.com/users/yuri-polessky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuri-polessky/subscriptions","organizations_url":"https://api.github.com/users/yuri-polessky/orgs","repos_url":"https://api.github.com/users/yuri-polessky/repos","events_url":"https://api.github.com/users/yuri-polessky/events{/privacy}","received_events_url":"https://api.github.com/users/yuri-polessky/received_events","type":"User","site_admin":false},"repo":{"id":41664877,"name":"flashcards","full_name":"yuri-polessky/flashcards","owner":{"login":"yuri-polessky","id":9403076,"avatar_url":"https://avatars.githubusercontent.com/u/9403076?v=3","gravatar_id":"","url":"https://api.github.com/users/yuri-polessky","html_url":"https://github.com/yuri-polessky","followers_url":"https://api.github.com/users/yuri-polessky/followers","following_url":"https://api.github.com/users/yuri-polessky/following{/other_user}","gists_url":"https://api.github.com/users/yuri-polessky/gists{/gist_id}","starred_url":"https://api.github.com/users/yuri-polessky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuri-polessky/subscriptions","organizations_url":"https://api.github.com/users/yuri-polessky/orgs","repos_url":"https://api.github.com/users/yuri-polessky/repos","events_url":"https://api.github.com/users/yuri-polessky/events{/privacy}","received_events_url":"https://api.github.com/users/yuri-polessky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yuri-polessky/flashcards","description":"","fork":false,"url":"https://api.github.com/repos/yuri-polessky/flashcards","forks_url":"https://api.github.com/repos/yuri-polessky/flashcards/forks","keys_url":"https://api.github.com/repos/yuri-polessky/flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yuri-polessky/flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yuri-polessky/flashcards/teams","hooks_url":"https://api.github.com/repos/yuri-polessky/flashcards/hooks","issue_events_url":"https://api.github.com/repos/yuri-polessky/flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/yuri-polessky/flashcards/events","assignees_url":"https://api.github.com/repos/yuri-polessky/flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/yuri-polessky/flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/yuri-polessky/flashcards/tags","blobs_url":"https://api.github.com/repos/yuri-polessky/flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yuri-polessky/flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yuri-polessky/flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/yuri-polessky/flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yuri-polessky/flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/yuri-polessky/flashcards/languages","stargazers_url":"https://api.github.com/repos/yuri-polessky/flashcards/stargazers","contributors_url":"https://api.github.com/repos/yuri-polessky/flashcards/contributors","subscribers_url":"https://api.github.com/repos/yuri-polessky/flashcards/subscribers","subscription_url":"https://api.github.com/repos/yuri-polessky/flashcards/subscription","commits_url":"https://api.github.com/repos/yuri-polessky/flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/yuri-polessky/flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/yuri-polessky/flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/yuri-polessky/flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/yuri-polessky/flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/yuri-polessky/flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yuri-polessky/flashcards/merges","archive_url":"https://api.github.com/repos/yuri-polessky/flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yuri-polessky/flashcards/downloads","issues_url":"https://api.github.com/repos/yuri-polessky/flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/yuri-polessky/flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/yuri-polessky/flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/yuri-polessky/flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yuri-polessky/flashcards/labels{/name}","releases_url":"https://api.github.com/repos/yuri-polessky/flashcards/releases{/id}","created_at":"2015-08-31T08:35:45Z","updated_at":"2015-08-31T14:46:09Z","pushed_at":"2015-09-09T10:25:57Z","git_url":"git://github.com/yuri-polessky/flashcards.git","ssh_url":"git@github.com:yuri-polessky/flashcards.git","clone_url":"https://github.com/yuri-polessky/flashcards.git","svn_url":"https://github.com/yuri-polessky/flashcards","homepage":null,"size":344,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"yuri-polessky:master","ref":"master","sha":"398c0e67e3864f2ba7f05bc8013a58e3597452a5","user":{"login":"yuri-polessky","id":9403076,"avatar_url":"https://avatars.githubusercontent.com/u/9403076?v=3","gravatar_id":"","url":"https://api.github.com/users/yuri-polessky","html_url":"https://github.com/yuri-polessky","followers_url":"https://api.github.com/users/yuri-polessky/followers","following_url":"https://api.github.com/users/yuri-polessky/following{/other_user}","gists_url":"https://api.github.com/users/yuri-polessky/gists{/gist_id}","starred_url":"https://api.github.com/users/yuri-polessky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuri-polessky/subscriptions","organizations_url":"https://api.github.com/users/yuri-polessky/orgs","repos_url":"https://api.github.com/users/yuri-polessky/repos","events_url":"https://api.github.com/users/yuri-polessky/events{/privacy}","received_events_url":"https://api.github.com/users/yuri-polessky/received_events","type":"User","site_admin":false},"repo":{"id":41664877,"name":"flashcards","full_name":"yuri-polessky/flashcards","owner":{"login":"yuri-polessky","id":9403076,"avatar_url":"https://avatars.githubusercontent.com/u/9403076?v=3","gravatar_id":"","url":"https://api.github.com/users/yuri-polessky","html_url":"https://github.com/yuri-polessky","followers_url":"https://api.github.com/users/yuri-polessky/followers","following_url":"https://api.github.com/users/yuri-polessky/following{/other_user}","gists_url":"https://api.github.com/users/yuri-polessky/gists{/gist_id}","starred_url":"https://api.github.com/users/yuri-polessky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuri-polessky/subscriptions","organizations_url":"https://api.github.com/users/yuri-polessky/orgs","repos_url":"https://api.github.com/users/yuri-polessky/repos","events_url":"https://api.github.com/users/yuri-polessky/events{/privacy}","received_events_url":"https://api.github.com/users/yuri-polessky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yuri-polessky/flashcards","description":"","fork":false,"url":"https://api.github.com/repos/yuri-polessky/flashcards","forks_url":"https://api.github.com/repos/yuri-polessky/flashcards/forks","keys_url":"https://api.github.com/repos/yuri-polessky/flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yuri-polessky/flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yuri-polessky/flashcards/teams","hooks_url":"https://api.github.com/repos/yuri-polessky/flashcards/hooks","issue_events_url":"https://api.github.com/repos/yuri-polessky/flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/yuri-polessky/flashcards/events","assignees_url":"https://api.github.com/repos/yuri-polessky/flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/yuri-polessky/flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/yuri-polessky/flashcards/tags","blobs_url":"https://api.github.com/repos/yuri-polessky/flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yuri-polessky/flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yuri-polessky/flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/yuri-polessky/flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yuri-polessky/flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/yuri-polessky/flashcards/languages","stargazers_url":"https://api.github.com/repos/yuri-polessky/flashcards/stargazers","contributors_url":"https://api.github.com/repos/yuri-polessky/flashcards/contributors","subscribers_url":"https://api.github.com/repos/yuri-polessky/flashcards/subscribers","subscription_url":"https://api.github.com/repos/yuri-polessky/flashcards/subscription","commits_url":"https://api.github.com/repos/yuri-polessky/flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/yuri-polessky/flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/yuri-polessky/flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/yuri-polessky/flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/yuri-polessky/flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/yuri-polessky/flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yuri-polessky/flashcards/merges","archive_url":"https://api.github.com/repos/yuri-polessky/flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yuri-polessky/flashcards/downloads","issues_url":"https://api.github.com/repos/yuri-polessky/flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/yuri-polessky/flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/yuri-polessky/flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/yuri-polessky/flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yuri-polessky/flashcards/labels{/name}","releases_url":"https://api.github.com/repos/yuri-polessky/flashcards/releases{/id}","created_at":"2015-08-31T08:35:45Z","updated_at":"2015-08-31T14:46:09Z","pushed_at":"2015-09-09T10:25:57Z","git_url":"git://github.com/yuri-polessky/flashcards.git","ssh_url":"git@github.com:yuri-polessky/flashcards.git","clone_url":"https://github.com/yuri-polessky/flashcards.git","svn_url":"https://github.com/yuri-polessky/flashcards","homepage":null,"size":344,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/14"},"html":{"href":"https://github.com/yuri-polessky/flashcards/pull/14"},"issue":{"href":"https://api.github.com/repos/yuri-polessky/flashcards/issues/14"},"comments":{"href":"https://api.github.com/repos/yuri-polessky/flashcards/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yuri-polessky/flashcards/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/yuri-polessky/flashcards/statuses/97098d4bc914726e8b51ce56175f5f024460c134"}}}}