{"action":"created","comment":{"url":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/comments/211527214","pull_request_review_id":147962702,"id":211527214,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTUyNzIxNA==","diff_hunk":"@@ -210,8 +210,8 @@ extension ZMConversation {\n             hasUnreadUnsentMessage = false\n         }\n         \n-        guard let messageTimestamp = message.serverTimestampIncludingChildMessages, let unreadTimestamp = lastUnreadMessage(olderOrEqualThan: messageTimestamp)?.serverTimestamp else { return }\n-        \n+        guard let messageTimestamp = message.serverTimestampIncludingChildMessages,\n+            let unreadTimestamp = lastUnreadMessage(olderOrEqualThan: messageTimestamp)?.serverTimestamp else { return }","path":"Source/Model/Conversation/ZMConversation+Timestamps.swift","position":7,"original_position":7,"commit_id":"7977143e1f8be18aa938561eece5a20d6aa817aa","original_commit_id":"7977143e1f8be18aa938561eece5a20d6aa817aa","user":{"login":"marcoconti83","id":620000,"node_id":"MDQ6VXNlcjYyMDAwMA==","avatar_url":"https://avatars2.githubusercontent.com/u/620000?v=4","gravatar_id":"","url":"https://api.github.com/users/marcoconti83","html_url":"https://github.com/marcoconti83","followers_url":"https://api.github.com/users/marcoconti83/followers","following_url":"https://api.github.com/users/marcoconti83/following{/other_user}","gists_url":"https://api.github.com/users/marcoconti83/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoconti83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoconti83/subscriptions","organizations_url":"https://api.github.com/users/marcoconti83/orgs","repos_url":"https://api.github.com/users/marcoconti83/repos","events_url":"https://api.github.com/users/marcoconti83/events{/privacy}","received_events_url":"https://api.github.com/users/marcoconti83/received_events","type":"User","site_admin":false},"body":"I think that's a good plan (remove separately to isolate any issue)","created_at":"2018-08-21T08:53:38Z","updated_at":"2018-08-21T08:53:39Z","html_url":"https://github.com/wireapp/wire-ios-data-model/pull/534#discussion_r211527214","pull_request_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/534","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/comments/211527214"},"html":{"href":"https://github.com/wireapp/wire-ios-data-model/pull/534#discussion_r211527214"},"pull_request":{"href":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/534"}},"in_reply_to_id":211307517},"pull_request":{"url":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/534","id":207335055,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3MzM1MDU1","html_url":"https://github.com/wireapp/wire-ios-data-model/pull/534","diff_url":"https://github.com/wireapp/wire-ios-data-model/pull/534.diff","patch_url":"https://github.com/wireapp/wire-ios-data-model/pull/534.patch","issue_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/issues/534","number":534,"state":"open","locked":false,"title":"Unordered relation Conversation->Messages","user":{"login":"mikeger","id":715129,"node_id":"MDQ6VXNlcjcxNTEyOQ==","avatar_url":"https://avatars3.githubusercontent.com/u/715129?v=4","gravatar_id":"","url":"https://api.github.com/users/mikeger","html_url":"https://github.com/mikeger","followers_url":"https://api.github.com/users/mikeger/followers","following_url":"https://api.github.com/users/mikeger/following{/other_user}","gists_url":"https://api.github.com/users/mikeger/gists{/gist_id}","starred_url":"https://api.github.com/users/mikeger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikeger/subscriptions","organizations_url":"https://api.github.com/users/mikeger/orgs","repos_url":"https://api.github.com/users/mikeger/repos","events_url":"https://api.github.com/users/mikeger/events{/privacy}","received_events_url":"https://api.github.com/users/mikeger/received_events","type":"User","site_admin":false},"body":"## What's new in this PR?\r\n\r\n### Issues\r\n\r\nThe performance of adding the message to the conversation was degrading in the bigger (50K messages+) conversations.\r\n\r\n### Causes\r\n\r\nDuring the WWDC, we identified that using the ordered relations in CoreData can cause the performance degradation.\r\n\r\n### Solutions\r\n\r\n1. Migration:\r\n    1.a Rename the relation `conversation.messages` to `conversation.allMessages`.\r\n    1.b Change the relation `conversation.allMessages`, `conversation.hiddenMessages` to be not ordered.\r\n\r\n2. (Re-)Introduce property `conversation.messages` backed by the fetch request (with the fetch limit). This would allow to keep the old code working.\r\n3. Remove all code for manually sorting the messages (sortedInsert...).\r\n4. Remove custom merge policy, since it's needed to resort messages and it's loading all messages into memory.\r\n5. Remove `messageWindow`.\r\n6. Check every usage of `conversation.messages` to make sure it's OK to look only on the most recent messages subset. For example: when inserting system message, we are checking if the last message is of the same type, so not necessary to load all messages, we try to find the dependency message for this one, it's also fine not to look on all the messages, etc.\r\n","created_at":"2018-08-09T14:26:01Z","updated_at":"2018-08-21T08:53:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a78068b5ad946dbc5d8ff3dfe46471b27100c8bb","assignee":null,"assignees":[],"requested_reviewers":[{"login":"marcoconti83","id":620000,"node_id":"MDQ6VXNlcjYyMDAwMA==","avatar_url":"https://avatars2.githubusercontent.com/u/620000?v=4","gravatar_id":"","url":"https://api.github.com/users/marcoconti83","html_url":"https://github.com/marcoconti83","followers_url":"https://api.github.com/users/marcoconti83/followers","following_url":"https://api.github.com/users/marcoconti83/following{/other_user}","gists_url":"https://api.github.com/users/marcoconti83/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoconti83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoconti83/subscriptions","organizations_url":"https://api.github.com/users/marcoconti83/orgs","repos_url":"https://api.github.com/users/marcoconti83/repos","events_url":"https://api.github.com/users/marcoconti83/events{/privacy}","received_events_url":"https://api.github.com/users/marcoconti83/received_events","type":"User","site_admin":false},{"login":"daehn","id":4603353,"node_id":"MDQ6VXNlcjQ2MDMzNTM=","avatar_url":"https://avatars3.githubusercontent.com/u/4603353?v=4","gravatar_id":"","url":"https://api.github.com/users/daehn","html_url":"https://github.com/daehn","followers_url":"https://api.github.com/users/daehn/followers","following_url":"https://api.github.com/users/daehn/following{/other_user}","gists_url":"https://api.github.com/users/daehn/gists{/gist_id}","starred_url":"https://api.github.com/users/daehn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daehn/subscriptions","organizations_url":"https://api.github.com/users/daehn/orgs","repos_url":"https://api.github.com/users/daehn/repos","events_url":"https://api.github.com/users/daehn/events{/privacy}","received_events_url":"https://api.github.com/users/daehn/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":414574640,"node_id":"MDU6TGFiZWw0MTQ1NzQ2NDA=","url":"https://api.github.com/repos/wireapp/wire-ios-data-model/labels/DO%20NOT%20MERGE","name":"DO NOT MERGE","color":"eb6420","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/534/commits","review_comments_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/534/comments","review_comment_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/issues/534/comments","statuses_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/statuses/7977143e1f8be18aa938561eece5a20d6aa817aa","head":{"label":"wireapp:feature/unordered-relations-masked","ref":"feature/unordered-relations-masked","sha":"7977143e1f8be18aa938561eece5a20d6aa817aa","user":{"login":"wireapp","id":16047324,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2MDQ3MzI0","avatar_url":"https://avatars3.githubusercontent.com/u/16047324?v=4","gravatar_id":"","url":"https://api.github.com/users/wireapp","html_url":"https://github.com/wireapp","followers_url":"https://api.github.com/users/wireapp/followers","following_url":"https://api.github.com/users/wireapp/following{/other_user}","gists_url":"https://api.github.com/users/wireapp/gists{/gist_id}","starred_url":"https://api.github.com/users/wireapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wireapp/subscriptions","organizations_url":"https://api.github.com/users/wireapp/orgs","repos_url":"https://api.github.com/users/wireapp/repos","events_url":"https://api.github.com/users/wireapp/events{/privacy}","received_events_url":"https://api.github.com/users/wireapp/received_events","type":"Organization","site_admin":false},"repo":{"id":57151009,"node_id":"MDEwOlJlcG9zaXRvcnk1NzE1MTAwOQ==","name":"wire-ios-data-model","full_name":"wireapp/wire-ios-data-model","owner":{"login":"wireapp","id":16047324,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2MDQ3MzI0","avatar_url":"https://avatars3.githubusercontent.com/u/16047324?v=4","gravatar_id":"","url":"https://api.github.com/users/wireapp","html_url":"https://github.com/wireapp","followers_url":"https://api.github.com/users/wireapp/followers","following_url":"https://api.github.com/users/wireapp/following{/other_user}","gists_url":"https://api.github.com/users/wireapp/gists{/gist_id}","starred_url":"https://api.github.com/users/wireapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wireapp/subscriptions","organizations_url":"https://api.github.com/users/wireapp/orgs","repos_url":"https://api.github.com/users/wireapp/repos","events_url":"https://api.github.com/users/wireapp/events{/privacy}","received_events_url":"https://api.github.com/users/wireapp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wireapp/wire-ios-data-model","description":"Core Data model and entity classes","fork":false,"url":"https://api.github.com/repos/wireapp/wire-ios-data-model","forks_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/forks","keys_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/teams","hooks_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/hooks","issue_events_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/issues/events{/number}","events_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/events","assignees_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/assignees{/user}","branches_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/branches{/branch}","tags_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/tags","blobs_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/git/refs{/sha}","trees_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/statuses/{sha}","languages_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/languages","stargazers_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/stargazers","contributors_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/contributors","subscribers_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/subscribers","subscription_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/subscription","commits_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/commits{/sha}","git_commits_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/git/commits{/sha}","comments_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/comments{/number}","issue_comment_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/issues/comments{/number}","contents_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/contents/{+path}","compare_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/merges","archive_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/downloads","issues_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/issues{/number}","pulls_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls{/number}","milestones_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/milestones{/number}","notifications_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/labels{/name}","releases_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/releases{/id}","deployments_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/deployments","created_at":"2016-04-26T18:09:28Z","updated_at":"2018-08-20T14:19:19Z","pushed_at":"2018-08-21T08:23:09Z","git_url":"git://github.com/wireapp/wire-ios-data-model.git","ssh_url":"git@github.com:wireapp/wire-ios-data-model.git","clone_url":"https://github.com/wireapp/wire-ios-data-model.git","svn_url":"https://github.com/wireapp/wire-ios-data-model","homepage":"https://wire.com","size":9799,"stargazers_count":21,"watchers_count":21,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":6,"open_issues":3,"watchers":21,"default_branch":"develop"}},"base":{"label":"wireapp:develop","ref":"develop","sha":"8f3c4eae91a337d8fcea20dc0d9c8211a3209032","user":{"login":"wireapp","id":16047324,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2MDQ3MzI0","avatar_url":"https://avatars3.githubusercontent.com/u/16047324?v=4","gravatar_id":"","url":"https://api.github.com/users/wireapp","html_url":"https://github.com/wireapp","followers_url":"https://api.github.com/users/wireapp/followers","following_url":"https://api.github.com/users/wireapp/following{/other_user}","gists_url":"https://api.github.com/users/wireapp/gists{/gist_id}","starred_url":"https://api.github.com/users/wireapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wireapp/subscriptions","organizations_url":"https://api.github.com/users/wireapp/orgs","repos_url":"https://api.github.com/users/wireapp/repos","events_url":"https://api.github.com/users/wireapp/events{/privacy}","received_events_url":"https://api.github.com/users/wireapp/received_events","type":"Organization","site_admin":false},"repo":{"id":57151009,"node_id":"MDEwOlJlcG9zaXRvcnk1NzE1MTAwOQ==","name":"wire-ios-data-model","full_name":"wireapp/wire-ios-data-model","owner":{"login":"wireapp","id":16047324,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2MDQ3MzI0","avatar_url":"https://avatars3.githubusercontent.com/u/16047324?v=4","gravatar_id":"","url":"https://api.github.com/users/wireapp","html_url":"https://github.com/wireapp","followers_url":"https://api.github.com/users/wireapp/followers","following_url":"https://api.github.com/users/wireapp/following{/other_user}","gists_url":"https://api.github.com/users/wireapp/gists{/gist_id}","starred_url":"https://api.github.com/users/wireapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wireapp/subscriptions","organizations_url":"https://api.github.com/users/wireapp/orgs","repos_url":"https://api.github.com/users/wireapp/repos","events_url":"https://api.github.com/users/wireapp/events{/privacy}","received_events_url":"https://api.github.com/users/wireapp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wireapp/wire-ios-data-model","description":"Core Data model and entity classes","fork":false,"url":"https://api.github.com/repos/wireapp/wire-ios-data-model","forks_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/forks","keys_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/teams","hooks_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/hooks","issue_events_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/issues/events{/number}","events_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/events","assignees_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/assignees{/user}","branches_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/branches{/branch}","tags_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/tags","blobs_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/git/refs{/sha}","trees_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/statuses/{sha}","languages_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/languages","stargazers_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/stargazers","contributors_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/contributors","subscribers_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/subscribers","subscription_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/subscription","commits_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/commits{/sha}","git_commits_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/git/commits{/sha}","comments_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/comments{/number}","issue_comment_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/issues/comments{/number}","contents_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/contents/{+path}","compare_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/merges","archive_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/downloads","issues_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/issues{/number}","pulls_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls{/number}","milestones_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/milestones{/number}","notifications_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/labels{/name}","releases_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/releases{/id}","deployments_url":"https://api.github.com/repos/wireapp/wire-ios-data-model/deployments","created_at":"2016-04-26T18:09:28Z","updated_at":"2018-08-20T14:19:19Z","pushed_at":"2018-08-21T08:23:09Z","git_url":"git://github.com/wireapp/wire-ios-data-model.git","ssh_url":"git@github.com:wireapp/wire-ios-data-model.git","clone_url":"https://github.com/wireapp/wire-ios-data-model.git","svn_url":"https://github.com/wireapp/wire-ios-data-model","homepage":"https://wire.com","size":9799,"stargazers_count":21,"watchers_count":21,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":6,"open_issues":3,"watchers":21,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/534"},"html":{"href":"https://github.com/wireapp/wire-ios-data-model/pull/534"},"issue":{"href":"https://api.github.com/repos/wireapp/wire-ios-data-model/issues/534"},"comments":{"href":"https://api.github.com/repos/wireapp/wire-ios-data-model/issues/534/comments"},"review_comments":{"href":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/534/comments"},"review_comment":{"href":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wireapp/wire-ios-data-model/pulls/534/commits"},"statuses":{"href":"https://api.github.com/repos/wireapp/wire-ios-data-model/statuses/7977143e1f8be18aa938561eece5a20d6aa817aa"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"marcoconti83"}}