{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/comments/53201861","id":53201861,"diff_hunk":"@@ -0,0 +1,176 @@\n+package models\n+\n+import org.joda.time.{Duration, DateTime}\n+import play.api.libs.json.{JsValue, Json}\n+import models.DateTimePoint\n+import models.StatsTable._\n+import models.Utils.round\n+\n+case class EmailStatsSeriesData (\n+                                  existingUndeliverables: List[DateTimePoint],\n+                                  existingUnsubscribes: List[DateTimePoint],\n+                                  hardBounces: List[DateTimePoint],\n+                                  softBounces: List[DateTimePoint],\n+                                  otherBounces: List[DateTimePoint],\n+                                  uniqueClicks: List[DateTimePoint],\n+                                  uniqueOpens: List[DateTimePoint],\n+                                  numberSent: List[DateTimePoint],\n+                                  numberDelivered: List[DateTimePoint],\n+                                  unsubscribes: List[DateTimePoint],\n+                                  openRate: Double = 0,\n+                                  clickthroughRate: Double = 0,\n+                                  weeklyOpenAvg: Double = 0,\n+                                  weeklyClickAvg: Double = 0\n+                                ) {\n+\n+  def ++ (b: EmailStatsSeriesData): EmailStatsSeriesData = {\n+    this.copy(\n+      this.existingUndeliverables ++ b.existingUndeliverables,\n+      this.existingUnsubscribes ++ b.existingUnsubscribes,\n+      this.hardBounces ++ b.hardBounces,\n+      this.softBounces ++ b.softBounces,\n+      this.otherBounces ++ b.otherBounces,\n+      this.uniqueClicks ++ b.uniqueClicks,\n+      this.uniqueOpens ++ b.uniqueOpens,\n+      this.numberSent ++ b.numberSent,\n+      this.numberDelivered ++ b.numberDelivered,\n+      this.unsubscribes ++ b.unsubscribes\n+    )\n+  }\n+\n+  def groupByDay = {\n+    this.copy(\n+      filterByDay(this.existingUndeliverables),\n+      filterByDay(this.existingUnsubscribes),\n+      filterByDay(this.hardBounces),\n+      filterByDay(this.softBounces),\n+      filterByDay(this.otherBounces),\n+      filterByDay(this.uniqueClicks),\n+      filterByDay(this.uniqueOpens),\n+      filterByDay(this.numberSent),\n+      filterByDay(this.numberDelivered),\n+      filterByDay(this.unsubscribes)\n+    )\n+  }\n+\n+  def filterByDay(items: List[DateTimePoint]): List[DateTimePoint] = {\n+    //work out total duration of time series\n+    val start = new DateTime(items.head.timestamp)","path":"app/models/EmailStatsSeriesData.scala","position":58,"original_position":58,"commit_id":"bb9f7b79ee092fc53f80c0a9a8309eb062736280","original_commit_id":"bb9f7b79ee092fc53f80c0a9a8309eb062736280","user":{"login":"janua","id":445472,"avatar_url":"https://avatars.githubusercontent.com/u/445472?v=3","gravatar_id":"","url":"https://api.github.com/users/janua","html_url":"https://github.com/janua","followers_url":"https://api.github.com/users/janua/followers","following_url":"https://api.github.com/users/janua/following{/other_user}","gists_url":"https://api.github.com/users/janua/gists{/gist_id}","starred_url":"https://api.github.com/users/janua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janua/subscriptions","organizations_url":"https://api.github.com/users/janua/orgs","repos_url":"https://api.github.com/users/janua/repos","events_url":"https://api.github.com/users/janua/events{/privacy}","received_events_url":"https://api.github.com/users/janua/received_events","type":"User","site_admin":false},"body":"Are you looking to frustrate yourself?","created_at":"2016-02-17T17:45:39Z","updated_at":"2016-02-17T17:45:39Z","html_url":"https://github.com/guardian/frontend-email-reporting/pull/26#discussion_r53201861","pull_request_url":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/comments/53201861"},"html":{"href":"https://github.com/guardian/frontend-email-reporting/pull/26#discussion_r53201861"},"pull_request":{"href":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/26","id":59673460,"html_url":"https://github.com/guardian/frontend-email-reporting/pull/26","diff_url":"https://github.com/guardian/frontend-email-reporting/pull/26.diff","patch_url":"https://github.com/guardian/frontend-email-reporting/pull/26.patch","issue_url":"https://api.github.com/repos/guardian/frontend-email-reporting/issues/26","number":26,"state":"open","locked":false,"title":"Adding average stats","user":{"login":"dominickendrick","id":1289259,"avatar_url":"https://avatars.githubusercontent.com/u/1289259?v=3","gravatar_id":"","url":"https://api.github.com/users/dominickendrick","html_url":"https://github.com/dominickendrick","followers_url":"https://api.github.com/users/dominickendrick/followers","following_url":"https://api.github.com/users/dominickendrick/following{/other_user}","gists_url":"https://api.github.com/users/dominickendrick/gists{/gist_id}","starred_url":"https://api.github.com/users/dominickendrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dominickendrick/subscriptions","organizations_url":"https://api.github.com/users/dominickendrick/orgs","repos_url":"https://api.github.com/users/dominickendrick/repos","events_url":"https://api.github.com/users/dominickendrick/events{/privacy}","received_events_url":"https://api.github.com/users/dominickendrick/received_events","type":"User","site_admin":false},"body":"This PR adds change against weekly average for clickthrough and open rate stats.\r\n\r\n**after:**\r\n<img width=\"1219\" alt=\"screen shot 2016-02-17 at 16 51 32\" src=\"https://cloud.githubusercontent.com/assets/1289259/13117154/b71eb04e-d596-11e5-9c26-2a9e47ee9d7a.png\">\r\n","created_at":"2016-02-17T16:52:09Z","updated_at":"2016-02-17T17:45:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1290f32f932aa89c5b0407d91f30d01e40da8414","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/26/commits","review_comments_url":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/26/comments","review_comment_url":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/frontend-email-reporting/issues/26/comments","statuses_url":"https://api.github.com/repos/guardian/frontend-email-reporting/statuses/bb9f7b79ee092fc53f80c0a9a8309eb062736280","head":{"label":"guardian:dk-add-weekly-average-change","ref":"dk-add-weekly-average-change","sha":"bb9f7b79ee092fc53f80c0a9a8309eb062736280","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":47612893,"name":"frontend-email-reporting","full_name":"guardian/frontend-email-reporting","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/frontend-email-reporting","description":"","fork":false,"url":"https://api.github.com/repos/guardian/frontend-email-reporting","forks_url":"https://api.github.com/repos/guardian/frontend-email-reporting/forks","keys_url":"https://api.github.com/repos/guardian/frontend-email-reporting/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/frontend-email-reporting/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/frontend-email-reporting/teams","hooks_url":"https://api.github.com/repos/guardian/frontend-email-reporting/hooks","issue_events_url":"https://api.github.com/repos/guardian/frontend-email-reporting/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/frontend-email-reporting/events","assignees_url":"https://api.github.com/repos/guardian/frontend-email-reporting/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/frontend-email-reporting/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/frontend-email-reporting/tags","blobs_url":"https://api.github.com/repos/guardian/frontend-email-reporting/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/frontend-email-reporting/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/frontend-email-reporting/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/frontend-email-reporting/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/frontend-email-reporting/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/frontend-email-reporting/languages","stargazers_url":"https://api.github.com/repos/guardian/frontend-email-reporting/stargazers","contributors_url":"https://api.github.com/repos/guardian/frontend-email-reporting/contributors","subscribers_url":"https://api.github.com/repos/guardian/frontend-email-reporting/subscribers","subscription_url":"https://api.github.com/repos/guardian/frontend-email-reporting/subscription","commits_url":"https://api.github.com/repos/guardian/frontend-email-reporting/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/frontend-email-reporting/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/frontend-email-reporting/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/frontend-email-reporting/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/frontend-email-reporting/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/frontend-email-reporting/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/frontend-email-reporting/merges","archive_url":"https://api.github.com/repos/guardian/frontend-email-reporting/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/frontend-email-reporting/downloads","issues_url":"https://api.github.com/repos/guardian/frontend-email-reporting/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/frontend-email-reporting/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/frontend-email-reporting/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/frontend-email-reporting/labels{/name}","releases_url":"https://api.github.com/repos/guardian/frontend-email-reporting/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/frontend-email-reporting/deployments","created_at":"2015-12-08T09:42:09Z","updated_at":"2016-01-11T17:46:05Z","pushed_at":"2016-02-17T17:21:31Z","git_url":"git://github.com/guardian/frontend-email-reporting.git","ssh_url":"git@github.com:guardian/frontend-email-reporting.git","clone_url":"https://github.com/guardian/frontend-email-reporting.git","svn_url":"https://github.com/guardian/frontend-email-reporting","homepage":null,"size":100,"stargazers_count":1,"watchers_count":1,"language":"Scala","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":1,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"e0c930d351a2fe211e49cbbd29cf59689edeb020","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":47612893,"name":"frontend-email-reporting","full_name":"guardian/frontend-email-reporting","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/frontend-email-reporting","description":"","fork":false,"url":"https://api.github.com/repos/guardian/frontend-email-reporting","forks_url":"https://api.github.com/repos/guardian/frontend-email-reporting/forks","keys_url":"https://api.github.com/repos/guardian/frontend-email-reporting/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/frontend-email-reporting/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/frontend-email-reporting/teams","hooks_url":"https://api.github.com/repos/guardian/frontend-email-reporting/hooks","issue_events_url":"https://api.github.com/repos/guardian/frontend-email-reporting/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/frontend-email-reporting/events","assignees_url":"https://api.github.com/repos/guardian/frontend-email-reporting/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/frontend-email-reporting/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/frontend-email-reporting/tags","blobs_url":"https://api.github.com/repos/guardian/frontend-email-reporting/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/frontend-email-reporting/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/frontend-email-reporting/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/frontend-email-reporting/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/frontend-email-reporting/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/frontend-email-reporting/languages","stargazers_url":"https://api.github.com/repos/guardian/frontend-email-reporting/stargazers","contributors_url":"https://api.github.com/repos/guardian/frontend-email-reporting/contributors","subscribers_url":"https://api.github.com/repos/guardian/frontend-email-reporting/subscribers","subscription_url":"https://api.github.com/repos/guardian/frontend-email-reporting/subscription","commits_url":"https://api.github.com/repos/guardian/frontend-email-reporting/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/frontend-email-reporting/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/frontend-email-reporting/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/frontend-email-reporting/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/frontend-email-reporting/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/frontend-email-reporting/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/frontend-email-reporting/merges","archive_url":"https://api.github.com/repos/guardian/frontend-email-reporting/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/frontend-email-reporting/downloads","issues_url":"https://api.github.com/repos/guardian/frontend-email-reporting/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/frontend-email-reporting/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/frontend-email-reporting/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/frontend-email-reporting/labels{/name}","releases_url":"https://api.github.com/repos/guardian/frontend-email-reporting/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/frontend-email-reporting/deployments","created_at":"2015-12-08T09:42:09Z","updated_at":"2016-01-11T17:46:05Z","pushed_at":"2016-02-17T17:21:31Z","git_url":"git://github.com/guardian/frontend-email-reporting.git","ssh_url":"git@github.com:guardian/frontend-email-reporting.git","clone_url":"https://github.com/guardian/frontend-email-reporting.git","svn_url":"https://github.com/guardian/frontend-email-reporting","homepage":null,"size":100,"stargazers_count":1,"watchers_count":1,"language":"Scala","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":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/26"},"html":{"href":"https://github.com/guardian/frontend-email-reporting/pull/26"},"issue":{"href":"https://api.github.com/repos/guardian/frontend-email-reporting/issues/26"},"comments":{"href":"https://api.github.com/repos/guardian/frontend-email-reporting/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/frontend-email-reporting/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/frontend-email-reporting/statuses/bb9f7b79ee092fc53f80c0a9a8309eb062736280"}}}}