{"action":"created","comment":{"url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/comments/35451103","id":35451103,"diff_hunk":"@@ -0,0 +1,53 @@\n+class SuperMemo\n+# http://www.supermemo.com/english/ol/sm2.htm\n+  class << self\n+    def set_efactor(efactor, quality)\n+      efactor = efactor + (0.1 - (5 - quality) * (0.08 + (5 - quality) * 0.02))\n+      efactor < 1.3 ? 1.3 : efactor\n+    end\n+\n+    def quality_helper(attempt, typos_count, seconds, subtrahend)\n+      if attempt == 0 && (0..10).include?(seconds)\n+        5 - subtrahend\n+      elsif (attempt == 0 && (11..20).include?(seconds)) ||\n+            (attempt == 1 && (0..20).include?(seconds))\n+        4 - subtrahend\n+      else\n+        3 - subtrahend\n+      end\n+    end\n+\n+    def set_quality(attempt, typos_count, seconds)\n+      if typos_count < 3\n+        quality_helper(attempt, typos_count, seconds, 0)\n+      else\n+        # Number '3' received as pattern and used for DRY)\n+        quality_helper(attempt, typos_count, seconds, 3)\n+      end\n+    end\n+\n+    def set_interval(efactor, interval, repeat)\n+      case repeat\n+      when 1 then 1\n+      when 2 then 6\n+      else\n+        (interval * efactor).round\n+      end\n+    end\n+\n+    def execute(attempt, efactor, interval, repeat, typos_count, seconds)\n+      quality = set_quality(attempt, typos_count)\n+      quality_by_time = set_quality_by_time(seconds, typos_count)\n+      quality = [quality, quality_by_time].min\n+      efactor = set_efactor(efactor, quality)\n+      repeat = quality < 3 ? 1 : repeat + 1\n+      interval = set_interval(efactor, interval, repeat)\n+      {\n+        efactor:  efactor,\n+        interval: interval,\n+        repeat:   repeat,","path":"app/services/super_memo.rb","position":46,"original_position":48,"commit_id":"24e659a32a3777d56f4760429ca4837578654145","original_commit_id":"2c4fce15c80719bc856e4c4bdcac201a09f6f2e9","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":"Unnecessary spacing detected.","created_at":"2015-07-24T18:23:23Z","updated_at":"2015-07-24T18:23:23Z","html_url":"https://github.com/DemidenkoAndrey/flashcards/pull/17#discussion_r35451103","pull_request_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/comments/35451103"},"html":{"href":"https://github.com/DemidenkoAndrey/flashcards/pull/17#discussion_r35451103"},"pull_request":{"href":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/17","id":40554981,"html_url":"https://github.com/DemidenkoAndrey/flashcards/pull/17","diff_url":"https://github.com/DemidenkoAndrey/flashcards/pull/17.diff","patch_url":"https://github.com/DemidenkoAndrey/flashcards/pull/17.patch","issue_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/issues/17","number":17,"state":"open","locked":false,"title":"Add supermemo and tests for it","user":{"login":"DemidenkoAndrey","id":8194192,"avatar_url":"https://avatars.githubusercontent.com/u/8194192?v=3","gravatar_id":"","url":"https://api.github.com/users/DemidenkoAndrey","html_url":"https://github.com/DemidenkoAndrey","followers_url":"https://api.github.com/users/DemidenkoAndrey/followers","following_url":"https://api.github.com/users/DemidenkoAndrey/following{/other_user}","gists_url":"https://api.github.com/users/DemidenkoAndrey/gists{/gist_id}","starred_url":"https://api.github.com/users/DemidenkoAndrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemidenkoAndrey/subscriptions","organizations_url":"https://api.github.com/users/DemidenkoAndrey/orgs","repos_url":"https://api.github.com/users/DemidenkoAndrey/repos","events_url":"https://api.github.com/users/DemidenkoAndrey/events{/privacy}","received_events_url":"https://api.github.com/users/DemidenkoAndrey/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-22T11:28:59Z","updated_at":"2015-07-24T18:23:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"19ec2faf723bf0bd42bccf8f5d785bc51766d2b2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/17/commits","review_comments_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/17/comments","review_comment_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/issues/17/comments","statuses_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/statuses/24e659a32a3777d56f4760429ca4837578654145","head":{"label":"DemidenkoAndrey:add-super-memo","ref":"add-super-memo","sha":"24e659a32a3777d56f4760429ca4837578654145","user":{"login":"DemidenkoAndrey","id":8194192,"avatar_url":"https://avatars.githubusercontent.com/u/8194192?v=3","gravatar_id":"","url":"https://api.github.com/users/DemidenkoAndrey","html_url":"https://github.com/DemidenkoAndrey","followers_url":"https://api.github.com/users/DemidenkoAndrey/followers","following_url":"https://api.github.com/users/DemidenkoAndrey/following{/other_user}","gists_url":"https://api.github.com/users/DemidenkoAndrey/gists{/gist_id}","starred_url":"https://api.github.com/users/DemidenkoAndrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemidenkoAndrey/subscriptions","organizations_url":"https://api.github.com/users/DemidenkoAndrey/orgs","repos_url":"https://api.github.com/users/DemidenkoAndrey/repos","events_url":"https://api.github.com/users/DemidenkoAndrey/events{/privacy}","received_events_url":"https://api.github.com/users/DemidenkoAndrey/received_events","type":"User","site_admin":false},"repo":{"id":34405016,"name":"flashcards","full_name":"DemidenkoAndrey/flashcards","owner":{"login":"DemidenkoAndrey","id":8194192,"avatar_url":"https://avatars.githubusercontent.com/u/8194192?v=3","gravatar_id":"","url":"https://api.github.com/users/DemidenkoAndrey","html_url":"https://github.com/DemidenkoAndrey","followers_url":"https://api.github.com/users/DemidenkoAndrey/followers","following_url":"https://api.github.com/users/DemidenkoAndrey/following{/other_user}","gists_url":"https://api.github.com/users/DemidenkoAndrey/gists{/gist_id}","starred_url":"https://api.github.com/users/DemidenkoAndrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemidenkoAndrey/subscriptions","organizations_url":"https://api.github.com/users/DemidenkoAndrey/orgs","repos_url":"https://api.github.com/users/DemidenkoAndrey/repos","events_url":"https://api.github.com/users/DemidenkoAndrey/events{/privacy}","received_events_url":"https://api.github.com/users/DemidenkoAndrey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DemidenkoAndrey/flashcards","description":"","fork":false,"url":"https://api.github.com/repos/DemidenkoAndrey/flashcards","forks_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/forks","keys_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/teams","hooks_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/hooks","issue_events_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/events","assignees_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/tags","blobs_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/languages","stargazers_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/stargazers","contributors_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/contributors","subscribers_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/subscribers","subscription_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/subscription","commits_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/merges","archive_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/downloads","issues_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/labels{/name}","releases_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/releases{/id}","created_at":"2015-04-22T17:25:31Z","updated_at":"2015-04-25T21:45:50Z","pushed_at":"2015-07-24T12:41:25Z","git_url":"git://github.com/DemidenkoAndrey/flashcards.git","ssh_url":"git@github.com:DemidenkoAndrey/flashcards.git","clone_url":"https://github.com/DemidenkoAndrey/flashcards.git","svn_url":"https://github.com/DemidenkoAndrey/flashcards","homepage":null,"size":1016,"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":"DemidenkoAndrey:master","ref":"master","sha":"e2bef6afafa6e541b2c9ade1625628cca63d9dc4","user":{"login":"DemidenkoAndrey","id":8194192,"avatar_url":"https://avatars.githubusercontent.com/u/8194192?v=3","gravatar_id":"","url":"https://api.github.com/users/DemidenkoAndrey","html_url":"https://github.com/DemidenkoAndrey","followers_url":"https://api.github.com/users/DemidenkoAndrey/followers","following_url":"https://api.github.com/users/DemidenkoAndrey/following{/other_user}","gists_url":"https://api.github.com/users/DemidenkoAndrey/gists{/gist_id}","starred_url":"https://api.github.com/users/DemidenkoAndrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemidenkoAndrey/subscriptions","organizations_url":"https://api.github.com/users/DemidenkoAndrey/orgs","repos_url":"https://api.github.com/users/DemidenkoAndrey/repos","events_url":"https://api.github.com/users/DemidenkoAndrey/events{/privacy}","received_events_url":"https://api.github.com/users/DemidenkoAndrey/received_events","type":"User","site_admin":false},"repo":{"id":34405016,"name":"flashcards","full_name":"DemidenkoAndrey/flashcards","owner":{"login":"DemidenkoAndrey","id":8194192,"avatar_url":"https://avatars.githubusercontent.com/u/8194192?v=3","gravatar_id":"","url":"https://api.github.com/users/DemidenkoAndrey","html_url":"https://github.com/DemidenkoAndrey","followers_url":"https://api.github.com/users/DemidenkoAndrey/followers","following_url":"https://api.github.com/users/DemidenkoAndrey/following{/other_user}","gists_url":"https://api.github.com/users/DemidenkoAndrey/gists{/gist_id}","starred_url":"https://api.github.com/users/DemidenkoAndrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemidenkoAndrey/subscriptions","organizations_url":"https://api.github.com/users/DemidenkoAndrey/orgs","repos_url":"https://api.github.com/users/DemidenkoAndrey/repos","events_url":"https://api.github.com/users/DemidenkoAndrey/events{/privacy}","received_events_url":"https://api.github.com/users/DemidenkoAndrey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DemidenkoAndrey/flashcards","description":"","fork":false,"url":"https://api.github.com/repos/DemidenkoAndrey/flashcards","forks_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/forks","keys_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/teams","hooks_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/hooks","issue_events_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/events","assignees_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/tags","blobs_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/languages","stargazers_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/stargazers","contributors_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/contributors","subscribers_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/subscribers","subscription_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/subscription","commits_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/merges","archive_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/downloads","issues_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/labels{/name}","releases_url":"https://api.github.com/repos/DemidenkoAndrey/flashcards/releases{/id}","created_at":"2015-04-22T17:25:31Z","updated_at":"2015-04-25T21:45:50Z","pushed_at":"2015-07-24T12:41:25Z","git_url":"git://github.com/DemidenkoAndrey/flashcards.git","ssh_url":"git@github.com:DemidenkoAndrey/flashcards.git","clone_url":"https://github.com/DemidenkoAndrey/flashcards.git","svn_url":"https://github.com/DemidenkoAndrey/flashcards","homepage":null,"size":1016,"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/DemidenkoAndrey/flashcards/pulls/17"},"html":{"href":"https://github.com/DemidenkoAndrey/flashcards/pull/17"},"issue":{"href":"https://api.github.com/repos/DemidenkoAndrey/flashcards/issues/17"},"comments":{"href":"https://api.github.com/repos/DemidenkoAndrey/flashcards/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DemidenkoAndrey/flashcards/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/DemidenkoAndrey/flashcards/statuses/24e659a32a3777d56f4760429ca4837578654145"}}}}