{"action":"created","comment":{"url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/comments/244900905","pull_request_review_id":188886139,"id":244900905,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDkwMDkwNQ==","diff_hunk":"@@ -0,0 +1,52 @@\n+//\n+//  SearchKeywordHistoryService.swift\n+//  swift-rindoku-sample\n+//\n+//  Created by SCI01254 on 2018/12/20.\n+//  Copyright © 2018 hicka04. All rights reserved.\n+//\n+\n+import Foundation\n+import RealmSwift\n+\n+// https://qiita.com/KeithYokoma/items/ee21fec6a3ebb5d1e9a8#%E3%83%87%E3%83%BC%E3%82%BF%E3%82%BD%E3%83%BC%E3%82%B9%E3%82%92%E5%8F%96%E3%82%8A%E6%89%B1%E3%81%86%E3%83%AC%E3%82%A4%E3%83%A4\n+// SearchKeywordHistoryStoreのほうが命名適切な気がします\n+class SearchKeywordHistoryStore {\n+    private let MAX_HISTORY_COUNT = 50\n+    private let realm = try! Realm()\n+\n+    // 今、printしかしてませんが\n+    // DBのラップをするならば、Realmに依存しない配列にできるといいと思います\n+    // 仮にDBをRealmじゃないものにするときに\n+    // 使っている側(今回でいうListViewController)は変更する必要がなくなります\n+    func findAll() -> [SearchKeywordHistory] {\n+        return Array(realm.objects(SearchKeywordHistory.self).sorted(byKeyPath: \"createdAt\", ascending: false))\n+    }\n+    // 必要なのはキーワードだけなのでStringにしてあげるといいと思います\n+    func findRecentKeyword() -> String? {\n+        return realm.objects(SearchKeywordHistory.self).sorted(byKeyPath: \"createdAt\", ascending: false).first?.keyword\n+    }\n+    // これはappend(_:)でしか使っていないので\n+    // メソッド切り出ししなくてもいい気がします\n+    private func findAllCreatedAtSortAsc() -> Results<SearchKeywordHistory>{\n+        return realm.objects(SearchKeywordHistory.self).sorted(byKeyPath: \"createdAt\", ascending: true)\n+    }\n+    // 必要なのはキーワードだけなのでStringを受け取るようにしたらいいとおもいます\n+    func append(keyword: String) {\n+        // 50件を超えるときだけ削除するが、保存処理は必ず行うので\n+        // if-elseにしないほうがそれを表現できると思います","path":"swift-rindoku-sample/SearchKeywordHistory/SearchKeywordHistoryStore.swift","position":37,"original_position":37,"commit_id":"64ab010631afd111a33b304d2bcfb27ea0da9409","original_commit_id":"64ab010631afd111a33b304d2bcfb27ea0da9409","user":{"login":"asamaki","id":5008198,"node_id":"MDQ6VXNlcjUwMDgxOTg=","avatar_url":"https://avatars1.githubusercontent.com/u/5008198?v=4","gravatar_id":"","url":"https://api.github.com/users/asamaki","html_url":"https://github.com/asamaki","followers_url":"https://api.github.com/users/asamaki/followers","following_url":"https://api.github.com/users/asamaki/following{/other_user}","gists_url":"https://api.github.com/users/asamaki/gists{/gist_id}","starred_url":"https://api.github.com/users/asamaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asamaki/subscriptions","organizations_url":"https://api.github.com/users/asamaki/orgs","repos_url":"https://api.github.com/users/asamaki/repos","events_url":"https://api.github.com/users/asamaki/events{/privacy}","received_events_url":"https://api.github.com/users/asamaki/received_events","type":"User","site_admin":false},"body":"これは少しはずかしいですね。ご指摘の通りです。ありがとうございます！","created_at":"2019-01-03T01:55:50Z","updated_at":"2019-01-03T01:55:50Z","html_url":"https://github.com/asamaki/swift-rindoku-sample/pull/1#discussion_r244900905","pull_request_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/1","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/comments/244900905"},"html":{"href":"https://github.com/asamaki/swift-rindoku-sample/pull/1#discussion_r244900905"},"pull_request":{"href":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/1","id":241664983,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQxNjY0OTgz","html_url":"https://github.com/asamaki/swift-rindoku-sample/pull/1","diff_url":"https://github.com/asamaki/swift-rindoku-sample/pull/1.diff","patch_url":"https://github.com/asamaki/swift-rindoku-sample/pull/1.patch","issue_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/issues/1","number":1,"state":"open","locked":false,"title":"レビュー内容に応じてコード変更","user":{"login":"hicka04","id":20559769,"node_id":"MDQ6VXNlcjIwNTU5NzY5","avatar_url":"https://avatars1.githubusercontent.com/u/20559769?v=4","gravatar_id":"","url":"https://api.github.com/users/hicka04","html_url":"https://github.com/hicka04","followers_url":"https://api.github.com/users/hicka04/followers","following_url":"https://api.github.com/users/hicka04/following{/other_user}","gists_url":"https://api.github.com/users/hicka04/gists{/gist_id}","starred_url":"https://api.github.com/users/hicka04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hicka04/subscriptions","organizations_url":"https://api.github.com/users/hicka04/orgs","repos_url":"https://api.github.com/users/hicka04/repos","events_url":"https://api.github.com/users/hicka04/events{/privacy}","received_events_url":"https://api.github.com/users/hicka04/received_events","type":"User","site_admin":false},"body":"","created_at":"2019-01-02T02:58:26Z","updated_at":"2019-01-03T01:55:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"806ecbc8f13d6532459b403b653f6f58444cbe03","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/1/commits","review_comments_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/1/comments","review_comment_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/comments{/number}","comments_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/issues/1/comments","statuses_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/statuses/64ab010631afd111a33b304d2bcfb27ea0da9409","head":{"label":"hicka04:feat/2019-01-review","ref":"feat/2019-01-review","sha":"64ab010631afd111a33b304d2bcfb27ea0da9409","user":{"login":"hicka04","id":20559769,"node_id":"MDQ6VXNlcjIwNTU5NzY5","avatar_url":"https://avatars1.githubusercontent.com/u/20559769?v=4","gravatar_id":"","url":"https://api.github.com/users/hicka04","html_url":"https://github.com/hicka04","followers_url":"https://api.github.com/users/hicka04/followers","following_url":"https://api.github.com/users/hicka04/following{/other_user}","gists_url":"https://api.github.com/users/hicka04/gists{/gist_id}","starred_url":"https://api.github.com/users/hicka04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hicka04/subscriptions","organizations_url":"https://api.github.com/users/hicka04/orgs","repos_url":"https://api.github.com/users/hicka04/repos","events_url":"https://api.github.com/users/hicka04/events{/privacy}","received_events_url":"https://api.github.com/users/hicka04/received_events","type":"User","site_admin":false},"repo":{"id":163781882,"node_id":"MDEwOlJlcG9zaXRvcnkxNjM3ODE4ODI=","name":"swift-rindoku-sample-1","full_name":"hicka04/swift-rindoku-sample-1","private":false,"owner":{"login":"hicka04","id":20559769,"node_id":"MDQ6VXNlcjIwNTU5NzY5","avatar_url":"https://avatars1.githubusercontent.com/u/20559769?v=4","gravatar_id":"","url":"https://api.github.com/users/hicka04","html_url":"https://github.com/hicka04","followers_url":"https://api.github.com/users/hicka04/followers","following_url":"https://api.github.com/users/hicka04/following{/other_user}","gists_url":"https://api.github.com/users/hicka04/gists{/gist_id}","starred_url":"https://api.github.com/users/hicka04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hicka04/subscriptions","organizations_url":"https://api.github.com/users/hicka04/orgs","repos_url":"https://api.github.com/users/hicka04/repos","events_url":"https://api.github.com/users/hicka04/events{/privacy}","received_events_url":"https://api.github.com/users/hicka04/received_events","type":"User","site_admin":false},"html_url":"https://github.com/hicka04/swift-rindoku-sample-1","description":null,"fork":true,"url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1","forks_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/forks","keys_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/teams","hooks_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/hooks","issue_events_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/issues/events{/number}","events_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/events","assignees_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/assignees{/user}","branches_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/branches{/branch}","tags_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/tags","blobs_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/statuses/{sha}","languages_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/languages","stargazers_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/stargazers","contributors_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/contributors","subscribers_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/subscribers","subscription_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/subscription","commits_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/contents/{+path}","compare_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/merges","archive_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/downloads","issues_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/issues{/number}","pulls_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/pulls{/number}","milestones_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/milestones{/number}","notifications_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/labels{/name}","releases_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/releases{/id}","deployments_url":"https://api.github.com/repos/hicka04/swift-rindoku-sample-1/deployments","created_at":"2019-01-02T01:51:35Z","updated_at":"2019-01-02T01:51:37Z","pushed_at":"2019-01-02T02:57:25Z","git_url":"git://github.com/hicka04/swift-rindoku-sample-1.git","ssh_url":"git@github.com:hicka04/swift-rindoku-sample-1.git","clone_url":"https://github.com/hicka04/swift-rindoku-sample-1.git","svn_url":"https://github.com/hicka04/swift-rindoku-sample-1","homepage":null,"size":27840,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"asamaki:master","ref":"master","sha":"af3b909093a14a3c0da5d773608d824e5902e1b9","user":{"login":"asamaki","id":5008198,"node_id":"MDQ6VXNlcjUwMDgxOTg=","avatar_url":"https://avatars1.githubusercontent.com/u/5008198?v=4","gravatar_id":"","url":"https://api.github.com/users/asamaki","html_url":"https://github.com/asamaki","followers_url":"https://api.github.com/users/asamaki/followers","following_url":"https://api.github.com/users/asamaki/following{/other_user}","gists_url":"https://api.github.com/users/asamaki/gists{/gist_id}","starred_url":"https://api.github.com/users/asamaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asamaki/subscriptions","organizations_url":"https://api.github.com/users/asamaki/orgs","repos_url":"https://api.github.com/users/asamaki/repos","events_url":"https://api.github.com/users/asamaki/events{/privacy}","received_events_url":"https://api.github.com/users/asamaki/received_events","type":"User","site_admin":false},"repo":{"id":162505516,"node_id":"MDEwOlJlcG9zaXRvcnkxNjI1MDU1MTY=","name":"swift-rindoku-sample","full_name":"asamaki/swift-rindoku-sample","private":false,"owner":{"login":"asamaki","id":5008198,"node_id":"MDQ6VXNlcjUwMDgxOTg=","avatar_url":"https://avatars1.githubusercontent.com/u/5008198?v=4","gravatar_id":"","url":"https://api.github.com/users/asamaki","html_url":"https://github.com/asamaki","followers_url":"https://api.github.com/users/asamaki/followers","following_url":"https://api.github.com/users/asamaki/following{/other_user}","gists_url":"https://api.github.com/users/asamaki/gists{/gist_id}","starred_url":"https://api.github.com/users/asamaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asamaki/subscriptions","organizations_url":"https://api.github.com/users/asamaki/orgs","repos_url":"https://api.github.com/users/asamaki/repos","events_url":"https://api.github.com/users/asamaki/events{/privacy}","received_events_url":"https://api.github.com/users/asamaki/received_events","type":"User","site_admin":false},"html_url":"https://github.com/asamaki/swift-rindoku-sample","description":null,"fork":false,"url":"https://api.github.com/repos/asamaki/swift-rindoku-sample","forks_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/forks","keys_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/teams","hooks_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/hooks","issue_events_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/issues/events{/number}","events_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/events","assignees_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/assignees{/user}","branches_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/branches{/branch}","tags_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/tags","blobs_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/git/refs{/sha}","trees_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/statuses/{sha}","languages_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/languages","stargazers_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/stargazers","contributors_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/contributors","subscribers_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/subscribers","subscription_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/subscription","commits_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/commits{/sha}","git_commits_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/git/commits{/sha}","comments_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/comments{/number}","issue_comment_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/issues/comments{/number}","contents_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/contents/{+path}","compare_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/merges","archive_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/downloads","issues_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/issues{/number}","pulls_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls{/number}","milestones_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/milestones{/number}","notifications_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/labels{/name}","releases_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/releases{/id}","deployments_url":"https://api.github.com/repos/asamaki/swift-rindoku-sample/deployments","created_at":"2018-12-20T00:26:35Z","updated_at":"2018-12-27T02:52:00Z","pushed_at":"2019-01-02T02:58:27Z","git_url":"git://github.com/asamaki/swift-rindoku-sample.git","ssh_url":"git@github.com:asamaki/swift-rindoku-sample.git","clone_url":"https://github.com/asamaki/swift-rindoku-sample.git","svn_url":"https://github.com/asamaki/swift-rindoku-sample","homepage":null,"size":27830,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/1"},"html":{"href":"https://github.com/asamaki/swift-rindoku-sample/pull/1"},"issue":{"href":"https://api.github.com/repos/asamaki/swift-rindoku-sample/issues/1"},"comments":{"href":"https://api.github.com/repos/asamaki/swift-rindoku-sample/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/asamaki/swift-rindoku-sample/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/asamaki/swift-rindoku-sample/statuses/64ab010631afd111a33b304d2bcfb27ea0da9409"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"asamaki"}}