{"action":"created","comment":{"url":"https://api.github.com/repos/krutman/flashcards/pulls/comments/39033580","id":39033580,"diff_hunk":"@@ -1,10 +1,29 @@\n class Card < ActiveRecord::Base\n   before_validation :set_review_date, on: :create\n-  default_scope -> { order('created_at DESC') }\n   validates :original_text, presence: true, length: { maximum: 100 }\n   validates :translated_text, presence: true, length: { maximum: 150 }\n   validates :review_date, presence: true\n   validate  :words_not_equal\n+\n+  scope :by_creation_time, -> { order('created_at DESC')  }\n+  scope :availables_for_check, -> { where('review_date <= ?', Date.today) }\n+  #scope :random_available_card, -> { availables_for_check.order('RANDOM()').first if availables_for_check.present? }\n+  \n+  def self.random_available_card\n+    if availables_for_check.present?\n+      availables_for_check.order('RANDOM()').first\n+    else\n+      nil\n+    end\n+  end\n+  ","path":"app/models/card.rb","position":20,"original_position":20,"commit_id":"af21767df087312bb7ed757806c4c7d682cab233","original_commit_id":"af21767df087312bb7ed757806c4c7d682cab233","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":"Trailing whitespace detected.","created_at":"2015-09-09T12:00:57Z","updated_at":"2015-09-09T12:00:57Z","html_url":"https://github.com/krutman/flashcards/pull/6#discussion_r39033580","pull_request_url":"https://api.github.com/repos/krutman/flashcards/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/krutman/flashcards/pulls/comments/39033580"},"html":{"href":"https://github.com/krutman/flashcards/pull/6#discussion_r39033580"},"pull_request":{"href":"https://api.github.com/repos/krutman/flashcards/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/krutman/flashcards/pulls/6","id":44540999,"html_url":"https://github.com/krutman/flashcards/pull/6","diff_url":"https://github.com/krutman/flashcards/pull/6.diff","patch_url":"https://github.com/krutman/flashcards/pull/6.patch","issue_url":"https://api.github.com/repos/krutman/flashcards/issues/6","number":6,"state":"open","locked":false,"title":"Add simple training","user":{"login":"krutman","id":8046696,"avatar_url":"https://avatars.githubusercontent.com/u/8046696?v=3","gravatar_id":"","url":"https://api.github.com/users/krutman","html_url":"https://github.com/krutman","followers_url":"https://api.github.com/users/krutman/followers","following_url":"https://api.github.com/users/krutman/following{/other_user}","gists_url":"https://api.github.com/users/krutman/gists{/gist_id}","starred_url":"https://api.github.com/users/krutman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krutman/subscriptions","organizations_url":"https://api.github.com/users/krutman/orgs","repos_url":"https://api.github.com/users/krutman/repos","events_url":"https://api.github.com/users/krutman/events{/privacy}","received_events_url":"https://api.github.com/users/krutman/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-09T12:00:53Z","updated_at":"2015-09-09T12:00:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d64e04a36847ca70a4de00cf84831b0ee7b1d28","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/krutman/flashcards/pulls/6/commits","review_comments_url":"https://api.github.com/repos/krutman/flashcards/pulls/6/comments","review_comment_url":"https://api.github.com/repos/krutman/flashcards/pulls/comments{/number}","comments_url":"https://api.github.com/repos/krutman/flashcards/issues/6/comments","statuses_url":"https://api.github.com/repos/krutman/flashcards/statuses/af21767df087312bb7ed757806c4c7d682cab233","head":{"label":"krutman:task-5","ref":"task-5","sha":"af21767df087312bb7ed757806c4c7d682cab233","user":{"login":"krutman","id":8046696,"avatar_url":"https://avatars.githubusercontent.com/u/8046696?v=3","gravatar_id":"","url":"https://api.github.com/users/krutman","html_url":"https://github.com/krutman","followers_url":"https://api.github.com/users/krutman/followers","following_url":"https://api.github.com/users/krutman/following{/other_user}","gists_url":"https://api.github.com/users/krutman/gists{/gist_id}","starred_url":"https://api.github.com/users/krutman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krutman/subscriptions","organizations_url":"https://api.github.com/users/krutman/orgs","repos_url":"https://api.github.com/users/krutman/repos","events_url":"https://api.github.com/users/krutman/events{/privacy}","received_events_url":"https://api.github.com/users/krutman/received_events","type":"User","site_admin":false},"repo":{"id":40921031,"name":"flashcards","full_name":"krutman/flashcards","owner":{"login":"krutman","id":8046696,"avatar_url":"https://avatars.githubusercontent.com/u/8046696?v=3","gravatar_id":"","url":"https://api.github.com/users/krutman","html_url":"https://github.com/krutman","followers_url":"https://api.github.com/users/krutman/followers","following_url":"https://api.github.com/users/krutman/following{/other_user}","gists_url":"https://api.github.com/users/krutman/gists{/gist_id}","starred_url":"https://api.github.com/users/krutman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krutman/subscriptions","organizations_url":"https://api.github.com/users/krutman/orgs","repos_url":"https://api.github.com/users/krutman/repos","events_url":"https://api.github.com/users/krutman/events{/privacy}","received_events_url":"https://api.github.com/users/krutman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/krutman/flashcards","description":"","fork":false,"url":"https://api.github.com/repos/krutman/flashcards","forks_url":"https://api.github.com/repos/krutman/flashcards/forks","keys_url":"https://api.github.com/repos/krutman/flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/krutman/flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/krutman/flashcards/teams","hooks_url":"https://api.github.com/repos/krutman/flashcards/hooks","issue_events_url":"https://api.github.com/repos/krutman/flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/krutman/flashcards/events","assignees_url":"https://api.github.com/repos/krutman/flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/krutman/flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/krutman/flashcards/tags","blobs_url":"https://api.github.com/repos/krutman/flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/krutman/flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/krutman/flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/krutman/flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/krutman/flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/krutman/flashcards/languages","stargazers_url":"https://api.github.com/repos/krutman/flashcards/stargazers","contributors_url":"https://api.github.com/repos/krutman/flashcards/contributors","subscribers_url":"https://api.github.com/repos/krutman/flashcards/subscribers","subscription_url":"https://api.github.com/repos/krutman/flashcards/subscription","commits_url":"https://api.github.com/repos/krutman/flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/krutman/flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/krutman/flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/krutman/flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/krutman/flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/krutman/flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/krutman/flashcards/merges","archive_url":"https://api.github.com/repos/krutman/flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/krutman/flashcards/downloads","issues_url":"https://api.github.com/repos/krutman/flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/krutman/flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/krutman/flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/krutman/flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/krutman/flashcards/labels{/name}","releases_url":"https://api.github.com/repos/krutman/flashcards/releases{/id}","created_at":"2015-08-17T19:05:54Z","updated_at":"2015-08-17T19:26:12Z","pushed_at":"2015-09-09T12:00:53Z","git_url":"git://github.com/krutman/flashcards.git","ssh_url":"git@github.com:krutman/flashcards.git","clone_url":"https://github.com/krutman/flashcards.git","svn_url":"https://github.com/krutman/flashcards","homepage":null,"size":368,"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":"krutman:master","ref":"master","sha":"87a8441e3ae009a9e3d66feb4f56d4b7620a8fb5","user":{"login":"krutman","id":8046696,"avatar_url":"https://avatars.githubusercontent.com/u/8046696?v=3","gravatar_id":"","url":"https://api.github.com/users/krutman","html_url":"https://github.com/krutman","followers_url":"https://api.github.com/users/krutman/followers","following_url":"https://api.github.com/users/krutman/following{/other_user}","gists_url":"https://api.github.com/users/krutman/gists{/gist_id}","starred_url":"https://api.github.com/users/krutman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krutman/subscriptions","organizations_url":"https://api.github.com/users/krutman/orgs","repos_url":"https://api.github.com/users/krutman/repos","events_url":"https://api.github.com/users/krutman/events{/privacy}","received_events_url":"https://api.github.com/users/krutman/received_events","type":"User","site_admin":false},"repo":{"id":40921031,"name":"flashcards","full_name":"krutman/flashcards","owner":{"login":"krutman","id":8046696,"avatar_url":"https://avatars.githubusercontent.com/u/8046696?v=3","gravatar_id":"","url":"https://api.github.com/users/krutman","html_url":"https://github.com/krutman","followers_url":"https://api.github.com/users/krutman/followers","following_url":"https://api.github.com/users/krutman/following{/other_user}","gists_url":"https://api.github.com/users/krutman/gists{/gist_id}","starred_url":"https://api.github.com/users/krutman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krutman/subscriptions","organizations_url":"https://api.github.com/users/krutman/orgs","repos_url":"https://api.github.com/users/krutman/repos","events_url":"https://api.github.com/users/krutman/events{/privacy}","received_events_url":"https://api.github.com/users/krutman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/krutman/flashcards","description":"","fork":false,"url":"https://api.github.com/repos/krutman/flashcards","forks_url":"https://api.github.com/repos/krutman/flashcards/forks","keys_url":"https://api.github.com/repos/krutman/flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/krutman/flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/krutman/flashcards/teams","hooks_url":"https://api.github.com/repos/krutman/flashcards/hooks","issue_events_url":"https://api.github.com/repos/krutman/flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/krutman/flashcards/events","assignees_url":"https://api.github.com/repos/krutman/flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/krutman/flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/krutman/flashcards/tags","blobs_url":"https://api.github.com/repos/krutman/flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/krutman/flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/krutman/flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/krutman/flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/krutman/flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/krutman/flashcards/languages","stargazers_url":"https://api.github.com/repos/krutman/flashcards/stargazers","contributors_url":"https://api.github.com/repos/krutman/flashcards/contributors","subscribers_url":"https://api.github.com/repos/krutman/flashcards/subscribers","subscription_url":"https://api.github.com/repos/krutman/flashcards/subscription","commits_url":"https://api.github.com/repos/krutman/flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/krutman/flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/krutman/flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/krutman/flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/krutman/flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/krutman/flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/krutman/flashcards/merges","archive_url":"https://api.github.com/repos/krutman/flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/krutman/flashcards/downloads","issues_url":"https://api.github.com/repos/krutman/flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/krutman/flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/krutman/flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/krutman/flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/krutman/flashcards/labels{/name}","releases_url":"https://api.github.com/repos/krutman/flashcards/releases{/id}","created_at":"2015-08-17T19:05:54Z","updated_at":"2015-08-17T19:26:12Z","pushed_at":"2015-09-09T12:00:53Z","git_url":"git://github.com/krutman/flashcards.git","ssh_url":"git@github.com:krutman/flashcards.git","clone_url":"https://github.com/krutman/flashcards.git","svn_url":"https://github.com/krutman/flashcards","homepage":null,"size":368,"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/krutman/flashcards/pulls/6"},"html":{"href":"https://github.com/krutman/flashcards/pull/6"},"issue":{"href":"https://api.github.com/repos/krutman/flashcards/issues/6"},"comments":{"href":"https://api.github.com/repos/krutman/flashcards/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/krutman/flashcards/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/krutman/flashcards/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/krutman/flashcards/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/krutman/flashcards/statuses/af21767df087312bb7ed757806c4c7d682cab233"}}}}