{"action":"created","comment":{"url":"https://api.github.com/repos/zendesk/radar/pulls/comments/42386415","id":42386415,"diff_hunk":"@@ -62,71 +63,97 @@ Client.create = function (message) {\n // Instance methods\n \n // Persist subscriptions and presences when not already persisted in memory\n-Client.prototype.storeData = function (message) {\n-  var subscriptions = this.subscriptions,\n-      presences = this.presences,\n-      changed = false,\n+Client.prototype.storeData = function (messageIn) {\n+  var subCount = Object.keys(this.subscriptions).length,\n+      presCount = Object.keys(this.presences).length,\n+      logNow = false;\n+\n+  // Persist the message data, according to type\n+  switch(messageIn.op) {\n+    case 'unsubscribe':\n+    case 'sync':\n+    case 'subscribe':\n+      logNow = this._storeDataSubscriptions(messageIn, subCount);\n+      break;\n+\n+    case 'set':\n+      logNow = this._storeDataPresences(messageIn);\n+      break;\n+  }\n+\n+  if (logNow) {","path":"client/client.js","position":34,"original_position":34,"commit_id":"5c2ed6128d2e2a798a66d2a70993284c86b026d7","original_commit_id":"5c2ed6128d2e2a798a66d2a70993284c86b026d7","user":{"login":"vanchi-zendesk","id":1341591,"avatar_url":"https://avatars.githubusercontent.com/u/1341591?v=3","gravatar_id":"","url":"https://api.github.com/users/vanchi-zendesk","html_url":"https://github.com/vanchi-zendesk","followers_url":"https://api.github.com/users/vanchi-zendesk/followers","following_url":"https://api.github.com/users/vanchi-zendesk/following{/other_user}","gists_url":"https://api.github.com/users/vanchi-zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/vanchi-zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanchi-zendesk/subscriptions","organizations_url":"https://api.github.com/users/vanchi-zendesk/orgs","repos_url":"https://api.github.com/users/vanchi-zendesk/repos","events_url":"https://api.github.com/users/vanchi-zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/vanchi-zendesk/received_events","type":"User","site_admin":false},"body":"let's always log for now, whenever there is actual data stored. Once we have this feature working fine, we can remove this logging altogether. \r\n\r\nBy the way, another approach to logging samples is simply `Math.random*100 < percentage`","created_at":"2015-10-19T15:36:21Z","updated_at":"2015-10-19T15:36:21Z","html_url":"https://github.com/zendesk/radar/pull/173#discussion_r42386415","pull_request_url":"https://api.github.com/repos/zendesk/radar/pulls/173","_links":{"self":{"href":"https://api.github.com/repos/zendesk/radar/pulls/comments/42386415"},"html":{"href":"https://github.com/zendesk/radar/pull/173#discussion_r42386415"},"pull_request":{"href":"https://api.github.com/repos/zendesk/radar/pulls/173"}}},"pull_request":{"url":"https://api.github.com/repos/zendesk/radar/pulls/173","id":47577790,"html_url":"https://github.com/zendesk/radar/pull/173","diff_url":"https://github.com/zendesk/radar/pull/173.diff","patch_url":"https://github.com/zendesk/radar/pull/173.patch","issue_url":"https://api.github.com/repos/zendesk/radar/issues/173","number":173,"state":"open","locked":false,"title":"Changes to fix storeData bug in client.js","user":{"login":"bolddane","id":5687737,"avatar_url":"https://avatars.githubusercontent.com/u/5687737?v=3","gravatar_id":"","url":"https://api.github.com/users/bolddane","html_url":"https://github.com/bolddane","followers_url":"https://api.github.com/users/bolddane/followers","following_url":"https://api.github.com/users/bolddane/following{/other_user}","gists_url":"https://api.github.com/users/bolddane/gists{/gist_id}","starred_url":"https://api.github.com/users/bolddane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bolddane/subscriptions","organizations_url":"https://api.github.com/users/bolddane/orgs","repos_url":"https://api.github.com/users/bolddane/repos","events_url":"https://api.github.com/users/bolddane/events{/privacy}","received_events_url":"https://api.github.com/users/bolddane/received_events","type":"User","site_admin":false},"body":"client.storeData was too bulky in terms of what it used to store in persistence, so I modified it to store only the \"to\" and \"op\" data for *subscriptions* and *presences*.  In addition, the old code stored an entire client instance each time a *subscription* or *presence* was modified; now it stores only a separate hash key/value pair for the relevant *subscription* or *presence* that is changed.  Logging has also been reduced by logging counts on every 10th change (we could make the logging window configurable, but I believe such complexity is not worth it.)\r\n\r\nIn persistence, two hashes are now created for each unique clientId, whereas before the whole server-side client was stored on a single key.\r\n\r\n/cc @zendesk/zendesk-radar\r\n\r\n### Steps to merge\r\n - [ ] :+1: of the team\r\n\r\n### References\r\n - Jira link: https://zendesk.atlassian.net/browse/RADAR-564\r\n\r\n### Risks\r\n - Low: Testing needs to be done locally to verify that redis data sizes are as expected","created_at":"2015-10-13T19:33:34Z","updated_at":"2015-10-19T15:36:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d93defa37ac42cdb491a1b94ea972f8a5d9c60aa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zendesk/radar/pulls/173/commits","review_comments_url":"https://api.github.com/repos/zendesk/radar/pulls/173/comments","review_comment_url":"https://api.github.com/repos/zendesk/radar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zendesk/radar/issues/173/comments","statuses_url":"https://api.github.com/repos/zendesk/radar/statuses/5c2ed6128d2e2a798a66d2a70993284c86b026d7","head":{"label":"zendesk:pobrien/fix_storedata_jira_564","ref":"pobrien/fix_storedata_jira_564","sha":"5c2ed6128d2e2a798a66d2a70993284c86b026d7","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":6050800,"name":"radar","full_name":"zendesk/radar","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/radar","description":"High level API and backend for writing web apps that use push messaging","fork":false,"url":"https://api.github.com/repos/zendesk/radar","forks_url":"https://api.github.com/repos/zendesk/radar/forks","keys_url":"https://api.github.com/repos/zendesk/radar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/radar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/radar/teams","hooks_url":"https://api.github.com/repos/zendesk/radar/hooks","issue_events_url":"https://api.github.com/repos/zendesk/radar/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/radar/events","assignees_url":"https://api.github.com/repos/zendesk/radar/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/radar/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/radar/tags","blobs_url":"https://api.github.com/repos/zendesk/radar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/radar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/radar/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/radar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/radar/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/radar/languages","stargazers_url":"https://api.github.com/repos/zendesk/radar/stargazers","contributors_url":"https://api.github.com/repos/zendesk/radar/contributors","subscribers_url":"https://api.github.com/repos/zendesk/radar/subscribers","subscription_url":"https://api.github.com/repos/zendesk/radar/subscription","commits_url":"https://api.github.com/repos/zendesk/radar/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/radar/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/radar/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/radar/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/radar/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/radar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/radar/merges","archive_url":"https://api.github.com/repos/zendesk/radar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/radar/downloads","issues_url":"https://api.github.com/repos/zendesk/radar/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/radar/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/radar/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/radar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/radar/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/radar/releases{/id}","created_at":"2012-10-02T20:15:07Z","updated_at":"2015-10-17T15:38:26Z","pushed_at":"2015-10-13T20:07:17Z","git_url":"git://github.com/zendesk/radar.git","ssh_url":"git@github.com:zendesk/radar.git","clone_url":"https://github.com/zendesk/radar.git","svn_url":"https://github.com/zendesk/radar","homepage":"http://radar.zendesk.com/","size":5222,"stargazers_count":164,"watchers_count":164,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":22,"mirror_url":null,"open_issues_count":10,"forks":22,"open_issues":10,"watchers":164,"default_branch":"master"}},"base":{"label":"zendesk:master","ref":"master","sha":"323b234d98c5c43176924a78c1f7a44160793aca","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":6050800,"name":"radar","full_name":"zendesk/radar","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/radar","description":"High level API and backend for writing web apps that use push messaging","fork":false,"url":"https://api.github.com/repos/zendesk/radar","forks_url":"https://api.github.com/repos/zendesk/radar/forks","keys_url":"https://api.github.com/repos/zendesk/radar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/radar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/radar/teams","hooks_url":"https://api.github.com/repos/zendesk/radar/hooks","issue_events_url":"https://api.github.com/repos/zendesk/radar/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/radar/events","assignees_url":"https://api.github.com/repos/zendesk/radar/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/radar/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/radar/tags","blobs_url":"https://api.github.com/repos/zendesk/radar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/radar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/radar/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/radar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/radar/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/radar/languages","stargazers_url":"https://api.github.com/repos/zendesk/radar/stargazers","contributors_url":"https://api.github.com/repos/zendesk/radar/contributors","subscribers_url":"https://api.github.com/repos/zendesk/radar/subscribers","subscription_url":"https://api.github.com/repos/zendesk/radar/subscription","commits_url":"https://api.github.com/repos/zendesk/radar/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/radar/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/radar/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/radar/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/radar/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/radar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/radar/merges","archive_url":"https://api.github.com/repos/zendesk/radar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/radar/downloads","issues_url":"https://api.github.com/repos/zendesk/radar/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/radar/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/radar/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/radar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/radar/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/radar/releases{/id}","created_at":"2012-10-02T20:15:07Z","updated_at":"2015-10-17T15:38:26Z","pushed_at":"2015-10-13T20:07:17Z","git_url":"git://github.com/zendesk/radar.git","ssh_url":"git@github.com:zendesk/radar.git","clone_url":"https://github.com/zendesk/radar.git","svn_url":"https://github.com/zendesk/radar","homepage":"http://radar.zendesk.com/","size":5222,"stargazers_count":164,"watchers_count":164,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":22,"mirror_url":null,"open_issues_count":10,"forks":22,"open_issues":10,"watchers":164,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendesk/radar/pulls/173"},"html":{"href":"https://github.com/zendesk/radar/pull/173"},"issue":{"href":"https://api.github.com/repos/zendesk/radar/issues/173"},"comments":{"href":"https://api.github.com/repos/zendesk/radar/issues/173/comments"},"review_comments":{"href":"https://api.github.com/repos/zendesk/radar/pulls/173/comments"},"review_comment":{"href":"https://api.github.com/repos/zendesk/radar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zendesk/radar/pulls/173/commits"},"statuses":{"href":"https://api.github.com/repos/zendesk/radar/statuses/5c2ed6128d2e2a798a66d2a70993284c86b026d7"}}}}