{"action":"created","comment":{"url":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/comments/325005802","pull_request_review_id":289050813,"id":325005802,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMyNTAwNTgwMg==","diff_hunk":"@@ -0,0 +1,58 @@\n+package com.softwaremill.janusz_backend.fourth_question;\n+\n+import com.softwaremill.janusz_backend.utils.NowProvider;\n+import lombok.RequiredArgsConstructor;\n+import org.springframework.stereotype.Component;\n+\n+import java.time.LocalDate;\n+import java.time.LocalDateTime;\n+import java.util.Optional;\n+\n+@Component\n+@RequiredArgsConstructor\n+class FourthQuestionHandler {\n+    private final FourthQuestionRepository fourthQuestionRepository;\n+    private final NowProvider nowProvider;\n+\n+    public long saveQuestion(NewQuestionDto newQuestion){\n+        LocalDateTime now = nowProvider.now();\n+        Question question = Question.newQuestion(\n+                newQuestion.getQuestion(),\n+                newQuestion.getAuthor(),\n+                now);\n+        fourthQuestionRepository.save(question);\n+        return fourthQuestionRepository.countByAskedDateIsNull();\n+    }\n+\n+    public Optional<TodayQuestionDto> getQuestion() {\n+        return queryTodayQuestion()\n+                .or(this::queryOldestUnaskedQuestionAndMarksAsAsked)\n+                .map(this::toQuestionResponse);\n+    }\n+\n+    private Optional<Question> queryTodayQuestion() {\n+        LocalDate today = getToday();\n+        return fourthQuestionRepository.findByAskedDate(today);\n+    }\n+\n+    private Optional<Question> queryOldestUnaskedQuestionAndMarksAsAsked() {\n+        return fourthQuestionRepository.findFirstByAskedDateIsNullOrderByAddedTimeAsc()\n+                .map(this::markAsAsked);\n+    }\n+\n+    private Question markAsAsked(Question question) {","path":"src/main/java/com/softwaremill/janusz_backend/fourth_question/FourthQuestionHandler.java","position":43,"original_position":43,"commit_id":"54435873a0fb063dad1f5f252b55e7d0443d76bc","original_commit_id":"54435873a0fb063dad1f5f252b55e7d0443d76bc","user":{"login":"Grandys","id":3820247,"node_id":"MDQ6VXNlcjM4MjAyNDc=","avatar_url":"https://avatars3.githubusercontent.com/u/3820247?v=4","gravatar_id":"","url":"https://api.github.com/users/Grandys","html_url":"https://github.com/Grandys","followers_url":"https://api.github.com/users/Grandys/followers","following_url":"https://api.github.com/users/Grandys/following{/other_user}","gists_url":"https://api.github.com/users/Grandys/gists{/gist_id}","starred_url":"https://api.github.com/users/Grandys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Grandys/subscriptions","organizations_url":"https://api.github.com/users/Grandys/orgs","repos_url":"https://api.github.com/users/Grandys/repos","events_url":"https://api.github.com/users/Grandys/events{/privacy}","received_events_url":"https://api.github.com/users/Grandys/received_events","type":"User","site_admin":false},"body":"Yes I am, renamed to `markAsAskedToday`","created_at":"2019-09-17T06:53:02Z","updated_at":"2019-09-17T06:53:02Z","html_url":"https://github.com/softwaremill/janusz-backend/pull/34#discussion_r325005802","pull_request_url":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/34","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/comments/325005802"},"html":{"href":"https://github.com/softwaremill/janusz-backend/pull/34#discussion_r325005802"},"pull_request":{"href":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/34"}},"in_reply_to_id":324738745},"pull_request":{"url":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/34","id":315942402,"node_id":"MDExOlB1bGxSZXF1ZXN0MzE1OTQyNDAy","html_url":"https://github.com/softwaremill/janusz-backend/pull/34","diff_url":"https://github.com/softwaremill/janusz-backend/pull/34.diff","patch_url":"https://github.com/softwaremill/janusz-backend/pull/34.patch","issue_url":"https://api.github.com/repos/softwaremill/janusz-backend/issues/34","number":34,"state":"open","locked":false,"title":"Fourth question","user":{"login":"Grandys","id":3820247,"node_id":"MDQ6VXNlcjM4MjAyNDc=","avatar_url":"https://avatars3.githubusercontent.com/u/3820247?v=4","gravatar_id":"","url":"https://api.github.com/users/Grandys","html_url":"https://github.com/Grandys","followers_url":"https://api.github.com/users/Grandys/followers","following_url":"https://api.github.com/users/Grandys/following{/other_user}","gists_url":"https://api.github.com/users/Grandys/gists{/gist_id}","starred_url":"https://api.github.com/users/Grandys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Grandys/subscriptions","organizations_url":"https://api.github.com/users/Grandys/orgs","repos_url":"https://api.github.com/users/Grandys/repos","events_url":"https://api.github.com/users/Grandys/events{/privacy}","received_events_url":"https://api.github.com/users/Grandys/received_events","type":"User","site_admin":false},"body":"Migration of fourth question functionality, from AWS lambda & DynamoDB to postgres.\r\nFurther steps required to finish migration:\r\n1. Change in janusz-the-boot, to invoke janusz-backend instead of AWS lambda\r\n2. Manual migration from DynamoDB to postgres.\r\n\r\nVoting is not implemented in this PR.","created_at":"2019-09-10T11:16:23Z","updated_at":"2019-09-17T06:53:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52c52095535329a102cda245e9a5ba9d1f0f0593","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/34/commits","review_comments_url":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/34/comments","review_comment_url":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/softwaremill/janusz-backend/issues/34/comments","statuses_url":"https://api.github.com/repos/softwaremill/janusz-backend/statuses/54435873a0fb063dad1f5f252b55e7d0443d76bc","head":{"label":"softwaremill:fourth-question","ref":"fourth-question","sha":"54435873a0fb063dad1f5f252b55e7d0443d76bc","user":{"login":"softwaremill","id":322765,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyMjc2NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/322765?v=4","gravatar_id":"","url":"https://api.github.com/users/softwaremill","html_url":"https://github.com/softwaremill","followers_url":"https://api.github.com/users/softwaremill/followers","following_url":"https://api.github.com/users/softwaremill/following{/other_user}","gists_url":"https://api.github.com/users/softwaremill/gists{/gist_id}","starred_url":"https://api.github.com/users/softwaremill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softwaremill/subscriptions","organizations_url":"https://api.github.com/users/softwaremill/orgs","repos_url":"https://api.github.com/users/softwaremill/repos","events_url":"https://api.github.com/users/softwaremill/events{/privacy}","received_events_url":"https://api.github.com/users/softwaremill/received_events","type":"Organization","site_admin":false},"repo":{"id":28669246,"node_id":"MDEwOlJlcG9zaXRvcnkyODY2OTI0Ng==","name":"janusz-backend","full_name":"softwaremill/janusz-backend","private":false,"owner":{"login":"softwaremill","id":322765,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyMjc2NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/322765?v=4","gravatar_id":"","url":"https://api.github.com/users/softwaremill","html_url":"https://github.com/softwaremill","followers_url":"https://api.github.com/users/softwaremill/followers","following_url":"https://api.github.com/users/softwaremill/following{/other_user}","gists_url":"https://api.github.com/users/softwaremill/gists{/gist_id}","starred_url":"https://api.github.com/users/softwaremill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softwaremill/subscriptions","organizations_url":"https://api.github.com/users/softwaremill/orgs","repos_url":"https://api.github.com/users/softwaremill/repos","events_url":"https://api.github.com/users/softwaremill/events{/privacy}","received_events_url":"https://api.github.com/users/softwaremill/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/softwaremill/janusz-backend","description":"Persistence module for grammar-checker script in Hubot running on Slack instance","fork":false,"url":"https://api.github.com/repos/softwaremill/janusz-backend","forks_url":"https://api.github.com/repos/softwaremill/janusz-backend/forks","keys_url":"https://api.github.com/repos/softwaremill/janusz-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/softwaremill/janusz-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/softwaremill/janusz-backend/teams","hooks_url":"https://api.github.com/repos/softwaremill/janusz-backend/hooks","issue_events_url":"https://api.github.com/repos/softwaremill/janusz-backend/issues/events{/number}","events_url":"https://api.github.com/repos/softwaremill/janusz-backend/events","assignees_url":"https://api.github.com/repos/softwaremill/janusz-backend/assignees{/user}","branches_url":"https://api.github.com/repos/softwaremill/janusz-backend/branches{/branch}","tags_url":"https://api.github.com/repos/softwaremill/janusz-backend/tags","blobs_url":"https://api.github.com/repos/softwaremill/janusz-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/softwaremill/janusz-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/softwaremill/janusz-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/softwaremill/janusz-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/softwaremill/janusz-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/softwaremill/janusz-backend/languages","stargazers_url":"https://api.github.com/repos/softwaremill/janusz-backend/stargazers","contributors_url":"https://api.github.com/repos/softwaremill/janusz-backend/contributors","subscribers_url":"https://api.github.com/repos/softwaremill/janusz-backend/subscribers","subscription_url":"https://api.github.com/repos/softwaremill/janusz-backend/subscription","commits_url":"https://api.github.com/repos/softwaremill/janusz-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/softwaremill/janusz-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/softwaremill/janusz-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/softwaremill/janusz-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/softwaremill/janusz-backend/contents/{+path}","compare_url":"https://api.github.com/repos/softwaremill/janusz-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/softwaremill/janusz-backend/merges","archive_url":"https://api.github.com/repos/softwaremill/janusz-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/softwaremill/janusz-backend/downloads","issues_url":"https://api.github.com/repos/softwaremill/janusz-backend/issues{/number}","pulls_url":"https://api.github.com/repos/softwaremill/janusz-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/softwaremill/janusz-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/softwaremill/janusz-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/softwaremill/janusz-backend/labels{/name}","releases_url":"https://api.github.com/repos/softwaremill/janusz-backend/releases{/id}","deployments_url":"https://api.github.com/repos/softwaremill/janusz-backend/deployments","created_at":"2014-12-31T15:46:16Z","updated_at":"2019-08-29T14:45:19Z","pushed_at":"2019-09-10T11:52:43Z","git_url":"git://github.com/softwaremill/janusz-backend.git","ssh_url":"git@github.com:softwaremill/janusz-backend.git","clone_url":"https://github.com/softwaremill/janusz-backend.git","svn_url":"https://github.com/softwaremill/janusz-backend","homepage":"","size":427,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":9,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":9,"watchers":3,"default_branch":"master"}},"base":{"label":"softwaremill:master","ref":"master","sha":"a1b4e7a771449f0061ad9ef2d05770d03ff058f6","user":{"login":"softwaremill","id":322765,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyMjc2NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/322765?v=4","gravatar_id":"","url":"https://api.github.com/users/softwaremill","html_url":"https://github.com/softwaremill","followers_url":"https://api.github.com/users/softwaremill/followers","following_url":"https://api.github.com/users/softwaremill/following{/other_user}","gists_url":"https://api.github.com/users/softwaremill/gists{/gist_id}","starred_url":"https://api.github.com/users/softwaremill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softwaremill/subscriptions","organizations_url":"https://api.github.com/users/softwaremill/orgs","repos_url":"https://api.github.com/users/softwaremill/repos","events_url":"https://api.github.com/users/softwaremill/events{/privacy}","received_events_url":"https://api.github.com/users/softwaremill/received_events","type":"Organization","site_admin":false},"repo":{"id":28669246,"node_id":"MDEwOlJlcG9zaXRvcnkyODY2OTI0Ng==","name":"janusz-backend","full_name":"softwaremill/janusz-backend","private":false,"owner":{"login":"softwaremill","id":322765,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyMjc2NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/322765?v=4","gravatar_id":"","url":"https://api.github.com/users/softwaremill","html_url":"https://github.com/softwaremill","followers_url":"https://api.github.com/users/softwaremill/followers","following_url":"https://api.github.com/users/softwaremill/following{/other_user}","gists_url":"https://api.github.com/users/softwaremill/gists{/gist_id}","starred_url":"https://api.github.com/users/softwaremill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softwaremill/subscriptions","organizations_url":"https://api.github.com/users/softwaremill/orgs","repos_url":"https://api.github.com/users/softwaremill/repos","events_url":"https://api.github.com/users/softwaremill/events{/privacy}","received_events_url":"https://api.github.com/users/softwaremill/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/softwaremill/janusz-backend","description":"Persistence module for grammar-checker script in Hubot running on Slack instance","fork":false,"url":"https://api.github.com/repos/softwaremill/janusz-backend","forks_url":"https://api.github.com/repos/softwaremill/janusz-backend/forks","keys_url":"https://api.github.com/repos/softwaremill/janusz-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/softwaremill/janusz-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/softwaremill/janusz-backend/teams","hooks_url":"https://api.github.com/repos/softwaremill/janusz-backend/hooks","issue_events_url":"https://api.github.com/repos/softwaremill/janusz-backend/issues/events{/number}","events_url":"https://api.github.com/repos/softwaremill/janusz-backend/events","assignees_url":"https://api.github.com/repos/softwaremill/janusz-backend/assignees{/user}","branches_url":"https://api.github.com/repos/softwaremill/janusz-backend/branches{/branch}","tags_url":"https://api.github.com/repos/softwaremill/janusz-backend/tags","blobs_url":"https://api.github.com/repos/softwaremill/janusz-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/softwaremill/janusz-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/softwaremill/janusz-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/softwaremill/janusz-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/softwaremill/janusz-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/softwaremill/janusz-backend/languages","stargazers_url":"https://api.github.com/repos/softwaremill/janusz-backend/stargazers","contributors_url":"https://api.github.com/repos/softwaremill/janusz-backend/contributors","subscribers_url":"https://api.github.com/repos/softwaremill/janusz-backend/subscribers","subscription_url":"https://api.github.com/repos/softwaremill/janusz-backend/subscription","commits_url":"https://api.github.com/repos/softwaremill/janusz-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/softwaremill/janusz-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/softwaremill/janusz-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/softwaremill/janusz-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/softwaremill/janusz-backend/contents/{+path}","compare_url":"https://api.github.com/repos/softwaremill/janusz-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/softwaremill/janusz-backend/merges","archive_url":"https://api.github.com/repos/softwaremill/janusz-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/softwaremill/janusz-backend/downloads","issues_url":"https://api.github.com/repos/softwaremill/janusz-backend/issues{/number}","pulls_url":"https://api.github.com/repos/softwaremill/janusz-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/softwaremill/janusz-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/softwaremill/janusz-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/softwaremill/janusz-backend/labels{/name}","releases_url":"https://api.github.com/repos/softwaremill/janusz-backend/releases{/id}","deployments_url":"https://api.github.com/repos/softwaremill/janusz-backend/deployments","created_at":"2014-12-31T15:46:16Z","updated_at":"2019-08-29T14:45:19Z","pushed_at":"2019-09-10T11:52:43Z","git_url":"git://github.com/softwaremill/janusz-backend.git","ssh_url":"git@github.com:softwaremill/janusz-backend.git","clone_url":"https://github.com/softwaremill/janusz-backend.git","svn_url":"https://github.com/softwaremill/janusz-backend","homepage":"","size":427,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":9,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":9,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/34"},"html":{"href":"https://github.com/softwaremill/janusz-backend/pull/34"},"issue":{"href":"https://api.github.com/repos/softwaremill/janusz-backend/issues/34"},"comments":{"href":"https://api.github.com/repos/softwaremill/janusz-backend/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/softwaremill/janusz-backend/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/softwaremill/janusz-backend/statuses/54435873a0fb063dad1f5f252b55e7d0443d76bc"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Grandys"}}