{"action":"created","comment":{"url":"https://api.github.com/repos/MistaTwista/flashcards/pulls/comments/43569996","id":43569996,"diff_hunk":"@@ -25,37 +19,39 @@ class Card < ActiveRecord::Base\n   validate :not_equal_fields\n   scope :for_review, -> { where(\"review_date < ?\", Time.now) }\n \n-  def check_translation(translation)\n+  def check_translation(translation, time)\n     l_distance = Text::Levenshtein.distance(translated_text, clear(translation))\n     if l_distance < LEVENSHTEIN_DISTANCE_MAXIMUM\n-      increase_review_level\n       correct = true\n+      get_next_interval(correct, time)\n     else\n-      decrease_review_level\n       correct = false\n+      get_next_interval(correct, time)\n     end\n     { correct: correct, levenshtein_distance: l_distance }\n   end\n \n-  def increase_review_level\n-    self.error_counter = 0\n-    if review_level < REVIEW_LEVELS\n-      self.review_level += 1\n-      new_date = Time.now + LEITNER_TIME[review_level]\n-      self.review_date = new_date\n+  def get_next_interval(correct, time)\n+    sm = SuperMemoService.new\n+    if correct\n+      q = quality_from_timer(time)\n+    else\n+      q = 0\n     end\n+    next_step = sm.next_step(q, memo_ef, memo_interval)\n+    self.memo_ef = next_step[:new_ef]\n+    self.memo_interval = next_step[:new_i]\n+    self.review_date = Time.now + memo_interval.seconds\n     save\n   end\n \n-  def decrease_review_level\n-    if review_level > 0\n-      if error_counter == ERRORS_TO_DECREASE\n-        self.review_level -= 1\n-        self.error_counter = 0\n-      else\n-        self.error_counter += 1\n-      end\n-      save\n+  def quality_from_timer(time)\n+    if time.to_i > SECONDS_TO_ANSWER[:slow]\n+      3\n+    elsif time.to_i > SECONDS_TO_ANSWER[:fast]\n+      4\n+    else\n+      5\n     end\n   end","path":"app/models/card.rb","position":79,"original_position":79,"commit_id":"e0bd63aaaae9f47eda5c518681921d1ac4039737","original_commit_id":"e0bd63aaaae9f47eda5c518681921d1ac4039737","user":{"login":"mkdev-mentor-1","id":11962702,"avatar_url":"https://avatars.githubusercontent.com/u/11962702?v=3","gravatar_id":"","url":"https://api.github.com/users/mkdev-mentor-1","html_url":"https://github.com/mkdev-mentor-1","followers_url":"https://api.github.com/users/mkdev-mentor-1/followers","following_url":"https://api.github.com/users/mkdev-mentor-1/following{/other_user}","gists_url":"https://api.github.com/users/mkdev-mentor-1/gists{/gist_id}","starred_url":"https://api.github.com/users/mkdev-mentor-1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkdev-mentor-1/subscriptions","organizations_url":"https://api.github.com/users/mkdev-mentor-1/orgs","repos_url":"https://api.github.com/users/mkdev-mentor-1/repos","events_url":"https://api.github.com/users/mkdev-mentor-1/events{/privacy}","received_events_url":"https://api.github.com/users/mkdev-mentor-1/received_events","type":"User","site_admin":false},"body":"quality пусть тоже внутри sm2 высчитывается","created_at":"2015-10-31T09:36:30Z","updated_at":"2015-10-31T09:36:30Z","html_url":"https://github.com/MistaTwista/flashcards/pull/19#discussion_r43569996","pull_request_url":"https://api.github.com/repos/MistaTwista/flashcards/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/MistaTwista/flashcards/pulls/comments/43569996"},"html":{"href":"https://github.com/MistaTwista/flashcards/pull/19#discussion_r43569996"},"pull_request":{"href":"https://api.github.com/repos/MistaTwista/flashcards/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/MistaTwista/flashcards/pulls/19","id":49331517,"html_url":"https://github.com/MistaTwista/flashcards/pull/19","diff_url":"https://github.com/MistaTwista/flashcards/pull/19.diff","patch_url":"https://github.com/MistaTwista/flashcards/pull/19.patch","issue_url":"https://api.github.com/repos/MistaTwista/flashcards/issues/19","number":19,"state":"open","locked":false,"title":"17 super memo","user":{"login":"MistaTwista","id":2895309,"avatar_url":"https://avatars.githubusercontent.com/u/2895309?v=3","gravatar_id":"","url":"https://api.github.com/users/MistaTwista","html_url":"https://github.com/MistaTwista","followers_url":"https://api.github.com/users/MistaTwista/followers","following_url":"https://api.github.com/users/MistaTwista/following{/other_user}","gists_url":"https://api.github.com/users/MistaTwista/gists{/gist_id}","starred_url":"https://api.github.com/users/MistaTwista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MistaTwista/subscriptions","organizations_url":"https://api.github.com/users/MistaTwista/orgs","repos_url":"https://api.github.com/users/MistaTwista/repos","events_url":"https://api.github.com/users/MistaTwista/events{/privacy}","received_events_url":"https://api.github.com/users/MistaTwista/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-30T22:55:39Z","updated_at":"2015-10-31T09:36:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f64a49730957647764a3b3ba63fbb9cafb296ef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/MistaTwista/flashcards/pulls/19/commits","review_comments_url":"https://api.github.com/repos/MistaTwista/flashcards/pulls/19/comments","review_comment_url":"https://api.github.com/repos/MistaTwista/flashcards/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MistaTwista/flashcards/issues/19/comments","statuses_url":"https://api.github.com/repos/MistaTwista/flashcards/statuses/e0bd63aaaae9f47eda5c518681921d1ac4039737","head":{"label":"MistaTwista:17-super-memo","ref":"17-super-memo","sha":"e0bd63aaaae9f47eda5c518681921d1ac4039737","user":{"login":"MistaTwista","id":2895309,"avatar_url":"https://avatars.githubusercontent.com/u/2895309?v=3","gravatar_id":"","url":"https://api.github.com/users/MistaTwista","html_url":"https://github.com/MistaTwista","followers_url":"https://api.github.com/users/MistaTwista/followers","following_url":"https://api.github.com/users/MistaTwista/following{/other_user}","gists_url":"https://api.github.com/users/MistaTwista/gists{/gist_id}","starred_url":"https://api.github.com/users/MistaTwista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MistaTwista/subscriptions","organizations_url":"https://api.github.com/users/MistaTwista/orgs","repos_url":"https://api.github.com/users/MistaTwista/repos","events_url":"https://api.github.com/users/MistaTwista/events{/privacy}","received_events_url":"https://api.github.com/users/MistaTwista/received_events","type":"User","site_admin":false},"repo":{"id":40986514,"name":"flashcards","full_name":"MistaTwista/flashcards","owner":{"login":"MistaTwista","id":2895309,"avatar_url":"https://avatars.githubusercontent.com/u/2895309?v=3","gravatar_id":"","url":"https://api.github.com/users/MistaTwista","html_url":"https://github.com/MistaTwista","followers_url":"https://api.github.com/users/MistaTwista/followers","following_url":"https://api.github.com/users/MistaTwista/following{/other_user}","gists_url":"https://api.github.com/users/MistaTwista/gists{/gist_id}","starred_url":"https://api.github.com/users/MistaTwista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MistaTwista/subscriptions","organizations_url":"https://api.github.com/users/MistaTwista/orgs","repos_url":"https://api.github.com/users/MistaTwista/repos","events_url":"https://api.github.com/users/MistaTwista/events{/privacy}","received_events_url":"https://api.github.com/users/MistaTwista/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MistaTwista/flashcards","description":"Flash cards apppication","fork":false,"url":"https://api.github.com/repos/MistaTwista/flashcards","forks_url":"https://api.github.com/repos/MistaTwista/flashcards/forks","keys_url":"https://api.github.com/repos/MistaTwista/flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MistaTwista/flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MistaTwista/flashcards/teams","hooks_url":"https://api.github.com/repos/MistaTwista/flashcards/hooks","issue_events_url":"https://api.github.com/repos/MistaTwista/flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/MistaTwista/flashcards/events","assignees_url":"https://api.github.com/repos/MistaTwista/flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/MistaTwista/flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/MistaTwista/flashcards/tags","blobs_url":"https://api.github.com/repos/MistaTwista/flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MistaTwista/flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MistaTwista/flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/MistaTwista/flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MistaTwista/flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/MistaTwista/flashcards/languages","stargazers_url":"https://api.github.com/repos/MistaTwista/flashcards/stargazers","contributors_url":"https://api.github.com/repos/MistaTwista/flashcards/contributors","subscribers_url":"https://api.github.com/repos/MistaTwista/flashcards/subscribers","subscription_url":"https://api.github.com/repos/MistaTwista/flashcards/subscription","commits_url":"https://api.github.com/repos/MistaTwista/flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/MistaTwista/flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/MistaTwista/flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/MistaTwista/flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/MistaTwista/flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/MistaTwista/flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MistaTwista/flashcards/merges","archive_url":"https://api.github.com/repos/MistaTwista/flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MistaTwista/flashcards/downloads","issues_url":"https://api.github.com/repos/MistaTwista/flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/MistaTwista/flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/MistaTwista/flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/MistaTwista/flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MistaTwista/flashcards/labels{/name}","releases_url":"https://api.github.com/repos/MistaTwista/flashcards/releases{/id}","created_at":"2015-08-18T17:22:12Z","updated_at":"2015-08-18T18:23:45Z","pushed_at":"2015-10-30T23:45:19Z","git_url":"git://github.com/MistaTwista/flashcards.git","ssh_url":"git@github.com:MistaTwista/flashcards.git","clone_url":"https://github.com/MistaTwista/flashcards.git","svn_url":"https://github.com/MistaTwista/flashcards","homepage":null,"size":900,"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":"MistaTwista:master","ref":"master","sha":"46818a3df0b90a1037f121ec5268210c764008a9","user":{"login":"MistaTwista","id":2895309,"avatar_url":"https://avatars.githubusercontent.com/u/2895309?v=3","gravatar_id":"","url":"https://api.github.com/users/MistaTwista","html_url":"https://github.com/MistaTwista","followers_url":"https://api.github.com/users/MistaTwista/followers","following_url":"https://api.github.com/users/MistaTwista/following{/other_user}","gists_url":"https://api.github.com/users/MistaTwista/gists{/gist_id}","starred_url":"https://api.github.com/users/MistaTwista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MistaTwista/subscriptions","organizations_url":"https://api.github.com/users/MistaTwista/orgs","repos_url":"https://api.github.com/users/MistaTwista/repos","events_url":"https://api.github.com/users/MistaTwista/events{/privacy}","received_events_url":"https://api.github.com/users/MistaTwista/received_events","type":"User","site_admin":false},"repo":{"id":40986514,"name":"flashcards","full_name":"MistaTwista/flashcards","owner":{"login":"MistaTwista","id":2895309,"avatar_url":"https://avatars.githubusercontent.com/u/2895309?v=3","gravatar_id":"","url":"https://api.github.com/users/MistaTwista","html_url":"https://github.com/MistaTwista","followers_url":"https://api.github.com/users/MistaTwista/followers","following_url":"https://api.github.com/users/MistaTwista/following{/other_user}","gists_url":"https://api.github.com/users/MistaTwista/gists{/gist_id}","starred_url":"https://api.github.com/users/MistaTwista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MistaTwista/subscriptions","organizations_url":"https://api.github.com/users/MistaTwista/orgs","repos_url":"https://api.github.com/users/MistaTwista/repos","events_url":"https://api.github.com/users/MistaTwista/events{/privacy}","received_events_url":"https://api.github.com/users/MistaTwista/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MistaTwista/flashcards","description":"Flash cards apppication","fork":false,"url":"https://api.github.com/repos/MistaTwista/flashcards","forks_url":"https://api.github.com/repos/MistaTwista/flashcards/forks","keys_url":"https://api.github.com/repos/MistaTwista/flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MistaTwista/flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MistaTwista/flashcards/teams","hooks_url":"https://api.github.com/repos/MistaTwista/flashcards/hooks","issue_events_url":"https://api.github.com/repos/MistaTwista/flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/MistaTwista/flashcards/events","assignees_url":"https://api.github.com/repos/MistaTwista/flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/MistaTwista/flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/MistaTwista/flashcards/tags","blobs_url":"https://api.github.com/repos/MistaTwista/flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MistaTwista/flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MistaTwista/flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/MistaTwista/flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MistaTwista/flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/MistaTwista/flashcards/languages","stargazers_url":"https://api.github.com/repos/MistaTwista/flashcards/stargazers","contributors_url":"https://api.github.com/repos/MistaTwista/flashcards/contributors","subscribers_url":"https://api.github.com/repos/MistaTwista/flashcards/subscribers","subscription_url":"https://api.github.com/repos/MistaTwista/flashcards/subscription","commits_url":"https://api.github.com/repos/MistaTwista/flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/MistaTwista/flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/MistaTwista/flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/MistaTwista/flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/MistaTwista/flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/MistaTwista/flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MistaTwista/flashcards/merges","archive_url":"https://api.github.com/repos/MistaTwista/flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MistaTwista/flashcards/downloads","issues_url":"https://api.github.com/repos/MistaTwista/flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/MistaTwista/flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/MistaTwista/flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/MistaTwista/flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MistaTwista/flashcards/labels{/name}","releases_url":"https://api.github.com/repos/MistaTwista/flashcards/releases{/id}","created_at":"2015-08-18T17:22:12Z","updated_at":"2015-08-18T18:23:45Z","pushed_at":"2015-10-30T23:45:19Z","git_url":"git://github.com/MistaTwista/flashcards.git","ssh_url":"git@github.com:MistaTwista/flashcards.git","clone_url":"https://github.com/MistaTwista/flashcards.git","svn_url":"https://github.com/MistaTwista/flashcards","homepage":null,"size":900,"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/MistaTwista/flashcards/pulls/19"},"html":{"href":"https://github.com/MistaTwista/flashcards/pull/19"},"issue":{"href":"https://api.github.com/repos/MistaTwista/flashcards/issues/19"},"comments":{"href":"https://api.github.com/repos/MistaTwista/flashcards/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/MistaTwista/flashcards/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/MistaTwista/flashcards/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MistaTwista/flashcards/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/MistaTwista/flashcards/statuses/e0bd63aaaae9f47eda5c518681921d1ac4039737"}}}}