{"action":"created","comment":{"url":"https://api.github.com/repos/ambiata/ivory/pulls/comments/36058242","id":36058242,"diff_hunk":"@@ -0,0 +1,47 @@\n+package com.ambiata.ivory.storage.statistics\n+\n+import com.ambiata.ivory.core._\n+import com.ambiata.mundane.control._\n+import com.ambiata.mundane.io._\n+import com.ambiata.notion.core._\n+\n+import argonaut._, Argonaut._\n+import scalaz._, Scalaz._\n+\n+object FactStatisticsStorage {\n+\n+  def toKeyStore(repo: Repository, key: Key, stats: FactStatistics): RIO[Unit] =\n+    repo.store.utf8.write(key, toJsonString(stats))\n+\n+  def fromKeyStore(repo: Repository, key: Key): RIO[String \\/ FactStatistics] =\n+    repo.store.utf8.read(key).map(fromJsonString)\n+\n+  def fromJsonString(str: String): String \\/ FactStatistics =\n+    Parse.decodeEither[FactStatistics](str)\n+\n+  def toJsonString(stats: FactStatistics): String =\n+    stats.asJson.spaces2\n+\n+  def fromMrOutput(location: IvoryLocation): RIO[String \\/ FactStatistics] = for {\n+    numerical   <- readJsonLines[NumericalFactStatistics](location </> DirPath.unsafe(\"numerical\"))\n+    categorical <- readJsonLines[CategoricalFactStatistics](location </> DirPath.unsafe(\"categorical\"))\n+  } yield for {\n+    _ <- (numerical.isEmpty && categorical.isEmpty).option(\"No stats to read\").toLeftDisjunction(())\n+    n <- numerical.getOrElse(Nil.right)\n+    c <- categorical.getOrElse(Nil.right)\n+  } yield FactStatistics(n, c, FactStatisticsVersion.V1)","path":"ivory-storage/src/main/scala/com/ambiata/ivory/storage/statistics/FactStatisticsStorage.scala","position":32,"original_position":32,"commit_id":"0f44ccf29056b438424368ffb06e6270fadc78e7","original_commit_id":"0f44ccf29056b438424368ffb06e6270fadc78e7","user":{"login":"charleso","id":31059,"avatar_url":"https://avatars.githubusercontent.com/u/31059?v=3","gravatar_id":"","url":"https://api.github.com/users/charleso","html_url":"https://github.com/charleso","followers_url":"https://api.github.com/users/charleso/followers","following_url":"https://api.github.com/users/charleso/following{/other_user}","gists_url":"https://api.github.com/users/charleso/gists{/gist_id}","starred_url":"https://api.github.com/users/charleso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charleso/subscriptions","organizations_url":"https://api.github.com/users/charleso/orgs","repos_url":"https://api.github.com/users/charleso/repos","events_url":"https://api.github.com/users/charleso/events{/privacy}","received_events_url":"https://api.github.com/users/charleso/received_events","type":"User","site_admin":false},"body":"Are you meant to be parsing out the version here? (And failing if it doesn't match)?","created_at":"2015-08-03T06:09:43Z","updated_at":"2015-08-03T06:09:43Z","html_url":"https://github.com/ambiata/ivory/pull/670#discussion_r36058242","pull_request_url":"https://api.github.com/repos/ambiata/ivory/pulls/670","_links":{"self":{"href":"https://api.github.com/repos/ambiata/ivory/pulls/comments/36058242"},"html":{"href":"https://github.com/ambiata/ivory/pull/670#discussion_r36058242"},"pull_request":{"href":"https://api.github.com/repos/ambiata/ivory/pulls/670"}}},"pull_request":{"url":"https://api.github.com/repos/ambiata/ivory/pulls/670","id":41092142,"html_url":"https://github.com/ambiata/ivory/pull/670","diff_url":"https://github.com/ambiata/ivory/pull/670.diff","patch_url":"https://github.com/ambiata/ivory/pull/670.patch","issue_url":"https://api.github.com/repos/ambiata/ivory/issues/670","number":670,"state":"open","locked":false,"title":"Move stats to raw mr","user":{"login":"raronson","id":1817744,"avatar_url":"https://avatars.githubusercontent.com/u/1817744?v=3","gravatar_id":"","url":"https://api.github.com/users/raronson","html_url":"https://github.com/raronson","followers_url":"https://api.github.com/users/raronson/followers","following_url":"https://api.github.com/users/raronson/following{/other_user}","gists_url":"https://api.github.com/users/raronson/gists{/gist_id}","starred_url":"https://api.github.com/users/raronson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raronson/subscriptions","organizations_url":"https://api.github.com/users/raronson/orgs","repos_url":"https://api.github.com/users/raronson/repos","events_url":"https://api.github.com/users/raronson/events{/privacy}","received_events_url":"https://api.github.com/users/raronson/received_events","type":"User","site_admin":false},"body":"Apologies for the big PR. Its all contained to the stats app though, so hopefully its not too long to review\r\n\r\n@markhibberd @HuwCampbell @charleso ","created_at":"2015-07-29T06:52:46Z","updated_at":"2015-08-03T06:09:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8309ee3fc8448937824ea9b57ad754bf2eeae292","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ambiata/ivory/pulls/670/commits","review_comments_url":"https://api.github.com/repos/ambiata/ivory/pulls/670/comments","review_comment_url":"https://api.github.com/repos/ambiata/ivory/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ambiata/ivory/issues/670/comments","statuses_url":"https://api.github.com/repos/ambiata/ivory/statuses/0f44ccf29056b438424368ffb06e6270fadc78e7","head":{"label":"ambiata:topic/stats-mr","ref":"topic/stats-mr","sha":"0f44ccf29056b438424368ffb06e6270fadc78e7","user":{"login":"ambiata","id":1691023,"avatar_url":"https://avatars.githubusercontent.com/u/1691023?v=3","gravatar_id":"","url":"https://api.github.com/users/ambiata","html_url":"https://github.com/ambiata","followers_url":"https://api.github.com/users/ambiata/followers","following_url":"https://api.github.com/users/ambiata/following{/other_user}","gists_url":"https://api.github.com/users/ambiata/gists{/gist_id}","starred_url":"https://api.github.com/users/ambiata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambiata/subscriptions","organizations_url":"https://api.github.com/users/ambiata/orgs","repos_url":"https://api.github.com/users/ambiata/repos","events_url":"https://api.github.com/users/ambiata/events{/privacy}","received_events_url":"https://api.github.com/users/ambiata/received_events","type":"Organization","site_admin":false},"repo":{"id":18756054,"name":"ivory","full_name":"ambiata/ivory","owner":{"login":"ambiata","id":1691023,"avatar_url":"https://avatars.githubusercontent.com/u/1691023?v=3","gravatar_id":"","url":"https://api.github.com/users/ambiata","html_url":"https://github.com/ambiata","followers_url":"https://api.github.com/users/ambiata/followers","following_url":"https://api.github.com/users/ambiata/following{/other_user}","gists_url":"https://api.github.com/users/ambiata/gists{/gist_id}","starred_url":"https://api.github.com/users/ambiata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambiata/subscriptions","organizations_url":"https://api.github.com/users/ambiata/orgs","repos_url":"https://api.github.com/users/ambiata/repos","events_url":"https://api.github.com/users/ambiata/events{/privacy}","received_events_url":"https://api.github.com/users/ambiata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ambiata/ivory","description":"A scalable and extensible data store for storing facts and extracting features.","fork":false,"url":"https://api.github.com/repos/ambiata/ivory","forks_url":"https://api.github.com/repos/ambiata/ivory/forks","keys_url":"https://api.github.com/repos/ambiata/ivory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ambiata/ivory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ambiata/ivory/teams","hooks_url":"https://api.github.com/repos/ambiata/ivory/hooks","issue_events_url":"https://api.github.com/repos/ambiata/ivory/issues/events{/number}","events_url":"https://api.github.com/repos/ambiata/ivory/events","assignees_url":"https://api.github.com/repos/ambiata/ivory/assignees{/user}","branches_url":"https://api.github.com/repos/ambiata/ivory/branches{/branch}","tags_url":"https://api.github.com/repos/ambiata/ivory/tags","blobs_url":"https://api.github.com/repos/ambiata/ivory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ambiata/ivory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ambiata/ivory/git/refs{/sha}","trees_url":"https://api.github.com/repos/ambiata/ivory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ambiata/ivory/statuses/{sha}","languages_url":"https://api.github.com/repos/ambiata/ivory/languages","stargazers_url":"https://api.github.com/repos/ambiata/ivory/stargazers","contributors_url":"https://api.github.com/repos/ambiata/ivory/contributors","subscribers_url":"https://api.github.com/repos/ambiata/ivory/subscribers","subscription_url":"https://api.github.com/repos/ambiata/ivory/subscription","commits_url":"https://api.github.com/repos/ambiata/ivory/commits{/sha}","git_commits_url":"https://api.github.com/repos/ambiata/ivory/git/commits{/sha}","comments_url":"https://api.github.com/repos/ambiata/ivory/comments{/number}","issue_comment_url":"https://api.github.com/repos/ambiata/ivory/issues/comments{/number}","contents_url":"https://api.github.com/repos/ambiata/ivory/contents/{+path}","compare_url":"https://api.github.com/repos/ambiata/ivory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ambiata/ivory/merges","archive_url":"https://api.github.com/repos/ambiata/ivory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ambiata/ivory/downloads","issues_url":"https://api.github.com/repos/ambiata/ivory/issues{/number}","pulls_url":"https://api.github.com/repos/ambiata/ivory/pulls{/number}","milestones_url":"https://api.github.com/repos/ambiata/ivory/milestones{/number}","notifications_url":"https://api.github.com/repos/ambiata/ivory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ambiata/ivory/labels{/name}","releases_url":"https://api.github.com/repos/ambiata/ivory/releases{/id}","created_at":"2014-04-14T09:54:53Z","updated_at":"2015-07-01T19:11:18Z","pushed_at":"2015-08-03T01:40:38Z","git_url":"git://github.com/ambiata/ivory.git","ssh_url":"git@github.com:ambiata/ivory.git","clone_url":"https://github.com/ambiata/ivory.git","svn_url":"https://github.com/ambiata/ivory","homepage":"","size":12737,"stargazers_count":53,"watchers_count":53,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":140,"forks":6,"open_issues":140,"watchers":53,"default_branch":"master"}},"base":{"label":"ambiata:master","ref":"master","sha":"54016b434db51e7bc7328501e5cb6b759b5280fd","user":{"login":"ambiata","id":1691023,"avatar_url":"https://avatars.githubusercontent.com/u/1691023?v=3","gravatar_id":"","url":"https://api.github.com/users/ambiata","html_url":"https://github.com/ambiata","followers_url":"https://api.github.com/users/ambiata/followers","following_url":"https://api.github.com/users/ambiata/following{/other_user}","gists_url":"https://api.github.com/users/ambiata/gists{/gist_id}","starred_url":"https://api.github.com/users/ambiata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambiata/subscriptions","organizations_url":"https://api.github.com/users/ambiata/orgs","repos_url":"https://api.github.com/users/ambiata/repos","events_url":"https://api.github.com/users/ambiata/events{/privacy}","received_events_url":"https://api.github.com/users/ambiata/received_events","type":"Organization","site_admin":false},"repo":{"id":18756054,"name":"ivory","full_name":"ambiata/ivory","owner":{"login":"ambiata","id":1691023,"avatar_url":"https://avatars.githubusercontent.com/u/1691023?v=3","gravatar_id":"","url":"https://api.github.com/users/ambiata","html_url":"https://github.com/ambiata","followers_url":"https://api.github.com/users/ambiata/followers","following_url":"https://api.github.com/users/ambiata/following{/other_user}","gists_url":"https://api.github.com/users/ambiata/gists{/gist_id}","starred_url":"https://api.github.com/users/ambiata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambiata/subscriptions","organizations_url":"https://api.github.com/users/ambiata/orgs","repos_url":"https://api.github.com/users/ambiata/repos","events_url":"https://api.github.com/users/ambiata/events{/privacy}","received_events_url":"https://api.github.com/users/ambiata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ambiata/ivory","description":"A scalable and extensible data store for storing facts and extracting features.","fork":false,"url":"https://api.github.com/repos/ambiata/ivory","forks_url":"https://api.github.com/repos/ambiata/ivory/forks","keys_url":"https://api.github.com/repos/ambiata/ivory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ambiata/ivory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ambiata/ivory/teams","hooks_url":"https://api.github.com/repos/ambiata/ivory/hooks","issue_events_url":"https://api.github.com/repos/ambiata/ivory/issues/events{/number}","events_url":"https://api.github.com/repos/ambiata/ivory/events","assignees_url":"https://api.github.com/repos/ambiata/ivory/assignees{/user}","branches_url":"https://api.github.com/repos/ambiata/ivory/branches{/branch}","tags_url":"https://api.github.com/repos/ambiata/ivory/tags","blobs_url":"https://api.github.com/repos/ambiata/ivory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ambiata/ivory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ambiata/ivory/git/refs{/sha}","trees_url":"https://api.github.com/repos/ambiata/ivory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ambiata/ivory/statuses/{sha}","languages_url":"https://api.github.com/repos/ambiata/ivory/languages","stargazers_url":"https://api.github.com/repos/ambiata/ivory/stargazers","contributors_url":"https://api.github.com/repos/ambiata/ivory/contributors","subscribers_url":"https://api.github.com/repos/ambiata/ivory/subscribers","subscription_url":"https://api.github.com/repos/ambiata/ivory/subscription","commits_url":"https://api.github.com/repos/ambiata/ivory/commits{/sha}","git_commits_url":"https://api.github.com/repos/ambiata/ivory/git/commits{/sha}","comments_url":"https://api.github.com/repos/ambiata/ivory/comments{/number}","issue_comment_url":"https://api.github.com/repos/ambiata/ivory/issues/comments{/number}","contents_url":"https://api.github.com/repos/ambiata/ivory/contents/{+path}","compare_url":"https://api.github.com/repos/ambiata/ivory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ambiata/ivory/merges","archive_url":"https://api.github.com/repos/ambiata/ivory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ambiata/ivory/downloads","issues_url":"https://api.github.com/repos/ambiata/ivory/issues{/number}","pulls_url":"https://api.github.com/repos/ambiata/ivory/pulls{/number}","milestones_url":"https://api.github.com/repos/ambiata/ivory/milestones{/number}","notifications_url":"https://api.github.com/repos/ambiata/ivory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ambiata/ivory/labels{/name}","releases_url":"https://api.github.com/repos/ambiata/ivory/releases{/id}","created_at":"2014-04-14T09:54:53Z","updated_at":"2015-07-01T19:11:18Z","pushed_at":"2015-08-03T01:40:38Z","git_url":"git://github.com/ambiata/ivory.git","ssh_url":"git@github.com:ambiata/ivory.git","clone_url":"https://github.com/ambiata/ivory.git","svn_url":"https://github.com/ambiata/ivory","homepage":"","size":12737,"stargazers_count":53,"watchers_count":53,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":140,"forks":6,"open_issues":140,"watchers":53,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ambiata/ivory/pulls/670"},"html":{"href":"https://github.com/ambiata/ivory/pull/670"},"issue":{"href":"https://api.github.com/repos/ambiata/ivory/issues/670"},"comments":{"href":"https://api.github.com/repos/ambiata/ivory/issues/670/comments"},"review_comments":{"href":"https://api.github.com/repos/ambiata/ivory/pulls/670/comments"},"review_comment":{"href":"https://api.github.com/repos/ambiata/ivory/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ambiata/ivory/pulls/670/commits"},"statuses":{"href":"https://api.github.com/repos/ambiata/ivory/statuses/0f44ccf29056b438424368ffb06e6270fadc78e7"}}}}