{"action":"created","comment":{"url":"https://api.github.com/repos/projecthydra/sufia/pulls/comments/52665187","id":52665187,"diff_hunk":"@@ -0,0 +1,44 @@\n+class WorkUsage\n+  attr_accessor :id, :created, :path, :downloads, :pageviews\n+\n+  def initialize(id)\n+    work = ::GenericWork.find(id)\n+    user = User.find_by(email: work.depositor)\n+    user_id = user ? user.id : nil\n+\n+    self.id = id\n+    self.path = Rails.application.routes.url_helpers.curation_concerns_generic_work_path(id)\n+    self.created = date_for_analytics(work)\n+    self.pageviews = WorkViewStat.to_flots WorkViewStat.statistics(id, created, user_id)\n+  end\n+\n+  # work.date_uploaded reflects the date the work was uploaded by the user\n+  # and therefore (if available) the date that we want to use for the stats\n+  # work.create_date reflects the date the work was added to Fedora. On data\n+  # migrated from one repository to another the created_date can be later\n+  # than the date the work was uploaded.\n+  def date_for_analytics(work)","path":"app/models/work_usage.rb","position":20,"original_position":20,"commit_id":"bcc1f87b124a11852e51c8a50be37b4e97d4b460","original_commit_id":"bcc1f87b124a11852e51c8a50be37b4e97d4b460","user":{"login":"jcoyne","id":92044,"avatar_url":"https://avatars.githubusercontent.com/u/92044?v=3","gravatar_id":"","url":"https://api.github.com/users/jcoyne","html_url":"https://github.com/jcoyne","followers_url":"https://api.github.com/users/jcoyne/followers","following_url":"https://api.github.com/users/jcoyne/following{/other_user}","gists_url":"https://api.github.com/users/jcoyne/gists{/gist_id}","starred_url":"https://api.github.com/users/jcoyne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcoyne/subscriptions","organizations_url":"https://api.github.com/users/jcoyne/orgs","repos_url":"https://api.github.com/users/jcoyne/repos","events_url":"https://api.github.com/users/jcoyne/events{/privacy}","received_events_url":"https://api.github.com/users/jcoyne/received_events","type":"User","site_admin":false},"body":"Should this be a private method? ","created_at":"2016-02-11T20:54:50Z","updated_at":"2016-02-11T20:54:50Z","html_url":"https://github.com/projecthydra/sufia/pull/1564#discussion_r52665187","pull_request_url":"https://api.github.com/repos/projecthydra/sufia/pulls/1564","_links":{"self":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/comments/52665187"},"html":{"href":"https://github.com/projecthydra/sufia/pull/1564#discussion_r52665187"},"pull_request":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/1564"}}},"pull_request":{"url":"https://api.github.com/repos/projecthydra/sufia/pulls/1564","id":58791447,"html_url":"https://github.com/projecthydra/sufia/pull/1564","diff_url":"https://github.com/projecthydra/sufia/pull/1564.diff","patch_url":"https://github.com/projecthydra/sufia/pull/1564.patch","issue_url":"https://api.github.com/repos/projecthydra/sufia/issues/1564","number":1564,"state":"open","locked":false,"title":"Work analytics","user":{"login":"gordonleacock","id":12927191,"avatar_url":"https://avatars.githubusercontent.com/u/12927191?v=3","gravatar_id":"","url":"https://api.github.com/users/gordonleacock","html_url":"https://github.com/gordonleacock","followers_url":"https://api.github.com/users/gordonleacock/followers","following_url":"https://api.github.com/users/gordonleacock/following{/other_user}","gists_url":"https://api.github.com/users/gordonleacock/gists{/gist_id}","starred_url":"https://api.github.com/users/gordonleacock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gordonleacock/subscriptions","organizations_url":"https://api.github.com/users/gordonleacock/orgs","repos_url":"https://api.github.com/users/gordonleacock/repos","events_url":"https://api.github.com/users/gordonleacock/events{/privacy}","received_events_url":"https://api.github.com/users/gordonleacock/received_events","type":"User","site_admin":false},"body":"Issue #1455, work in progress, no spec tests yet.","created_at":"2016-02-09T18:51:41Z","updated_at":"2016-02-11T20:54:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b58afd0d984514a2ad789bf7f85e49a7556bda75","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/projecthydra/sufia/pulls/1564/commits","review_comments_url":"https://api.github.com/repos/projecthydra/sufia/pulls/1564/comments","review_comment_url":"https://api.github.com/repos/projecthydra/sufia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/projecthydra/sufia/issues/1564/comments","statuses_url":"https://api.github.com/repos/projecthydra/sufia/statuses/bcc1f87b124a11852e51c8a50be37b4e97d4b460","head":{"label":"gordonleacock:work_analytics","ref":"work_analytics","sha":"bcc1f87b124a11852e51c8a50be37b4e97d4b460","user":{"login":"gordonleacock","id":12927191,"avatar_url":"https://avatars.githubusercontent.com/u/12927191?v=3","gravatar_id":"","url":"https://api.github.com/users/gordonleacock","html_url":"https://github.com/gordonleacock","followers_url":"https://api.github.com/users/gordonleacock/followers","following_url":"https://api.github.com/users/gordonleacock/following{/other_user}","gists_url":"https://api.github.com/users/gordonleacock/gists{/gist_id}","starred_url":"https://api.github.com/users/gordonleacock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gordonleacock/subscriptions","organizations_url":"https://api.github.com/users/gordonleacock/orgs","repos_url":"https://api.github.com/users/gordonleacock/repos","events_url":"https://api.github.com/users/gordonleacock/events{/privacy}","received_events_url":"https://api.github.com/users/gordonleacock/received_events","type":"User","site_admin":false},"repo":{"id":51161189,"name":"sufia","full_name":"gordonleacock/sufia","owner":{"login":"gordonleacock","id":12927191,"avatar_url":"https://avatars.githubusercontent.com/u/12927191?v=3","gravatar_id":"","url":"https://api.github.com/users/gordonleacock","html_url":"https://github.com/gordonleacock","followers_url":"https://api.github.com/users/gordonleacock/followers","following_url":"https://api.github.com/users/gordonleacock/following{/other_user}","gists_url":"https://api.github.com/users/gordonleacock/gists{/gist_id}","starred_url":"https://api.github.com/users/gordonleacock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gordonleacock/subscriptions","organizations_url":"https://api.github.com/users/gordonleacock/orgs","repos_url":"https://api.github.com/users/gordonleacock/repos","events_url":"https://api.github.com/users/gordonleacock/events{/privacy}","received_events_url":"https://api.github.com/users/gordonleacock/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gordonleacock/sufia","description":"Sufia extends the robust Hydra framework to provide a user interface around common repository features and social features. Sufia offers self-deposit and proxy deposit workflows with plans to develop one or more mediated deposit workflows in 2016. Sufia delivers its rich and growing set of features via a modern, responsive UI.","fork":true,"url":"https://api.github.com/repos/gordonleacock/sufia","forks_url":"https://api.github.com/repos/gordonleacock/sufia/forks","keys_url":"https://api.github.com/repos/gordonleacock/sufia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gordonleacock/sufia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gordonleacock/sufia/teams","hooks_url":"https://api.github.com/repos/gordonleacock/sufia/hooks","issue_events_url":"https://api.github.com/repos/gordonleacock/sufia/issues/events{/number}","events_url":"https://api.github.com/repos/gordonleacock/sufia/events","assignees_url":"https://api.github.com/repos/gordonleacock/sufia/assignees{/user}","branches_url":"https://api.github.com/repos/gordonleacock/sufia/branches{/branch}","tags_url":"https://api.github.com/repos/gordonleacock/sufia/tags","blobs_url":"https://api.github.com/repos/gordonleacock/sufia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gordonleacock/sufia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gordonleacock/sufia/git/refs{/sha}","trees_url":"https://api.github.com/repos/gordonleacock/sufia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gordonleacock/sufia/statuses/{sha}","languages_url":"https://api.github.com/repos/gordonleacock/sufia/languages","stargazers_url":"https://api.github.com/repos/gordonleacock/sufia/stargazers","contributors_url":"https://api.github.com/repos/gordonleacock/sufia/contributors","subscribers_url":"https://api.github.com/repos/gordonleacock/sufia/subscribers","subscription_url":"https://api.github.com/repos/gordonleacock/sufia/subscription","commits_url":"https://api.github.com/repos/gordonleacock/sufia/commits{/sha}","git_commits_url":"https://api.github.com/repos/gordonleacock/sufia/git/commits{/sha}","comments_url":"https://api.github.com/repos/gordonleacock/sufia/comments{/number}","issue_comment_url":"https://api.github.com/repos/gordonleacock/sufia/issues/comments{/number}","contents_url":"https://api.github.com/repos/gordonleacock/sufia/contents/{+path}","compare_url":"https://api.github.com/repos/gordonleacock/sufia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gordonleacock/sufia/merges","archive_url":"https://api.github.com/repos/gordonleacock/sufia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gordonleacock/sufia/downloads","issues_url":"https://api.github.com/repos/gordonleacock/sufia/issues{/number}","pulls_url":"https://api.github.com/repos/gordonleacock/sufia/pulls{/number}","milestones_url":"https://api.github.com/repos/gordonleacock/sufia/milestones{/number}","notifications_url":"https://api.github.com/repos/gordonleacock/sufia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gordonleacock/sufia/labels{/name}","releases_url":"https://api.github.com/repos/gordonleacock/sufia/releases{/id}","deployments_url":"https://api.github.com/repos/gordonleacock/sufia/deployments","created_at":"2016-02-05T17:07:13Z","updated_at":"2016-02-05T17:07:15Z","pushed_at":"2016-02-11T20:20:22Z","git_url":"git://github.com/gordonleacock/sufia.git","ssh_url":"git@github.com:gordonleacock/sufia.git","clone_url":"https://github.com/gordonleacock/sufia.git","svn_url":"https://github.com/gordonleacock/sufia","homepage":"http://sufia.io/","size":53918,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"projecthydra:master","ref":"master","sha":"c77658c6d161af8a26fc9a0bcf27ac0136a8528f","user":{"login":"projecthydra","id":109426,"avatar_url":"https://avatars.githubusercontent.com/u/109426?v=3","gravatar_id":"","url":"https://api.github.com/users/projecthydra","html_url":"https://github.com/projecthydra","followers_url":"https://api.github.com/users/projecthydra/followers","following_url":"https://api.github.com/users/projecthydra/following{/other_user}","gists_url":"https://api.github.com/users/projecthydra/gists{/gist_id}","starred_url":"https://api.github.com/users/projecthydra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projecthydra/subscriptions","organizations_url":"https://api.github.com/users/projecthydra/orgs","repos_url":"https://api.github.com/users/projecthydra/repos","events_url":"https://api.github.com/users/projecthydra/events{/privacy}","received_events_url":"https://api.github.com/users/projecthydra/received_events","type":"Organization","site_admin":false},"repo":{"id":7653178,"name":"sufia","full_name":"projecthydra/sufia","owner":{"login":"projecthydra","id":109426,"avatar_url":"https://avatars.githubusercontent.com/u/109426?v=3","gravatar_id":"","url":"https://api.github.com/users/projecthydra","html_url":"https://github.com/projecthydra","followers_url":"https://api.github.com/users/projecthydra/followers","following_url":"https://api.github.com/users/projecthydra/following{/other_user}","gists_url":"https://api.github.com/users/projecthydra/gists{/gist_id}","starred_url":"https://api.github.com/users/projecthydra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projecthydra/subscriptions","organizations_url":"https://api.github.com/users/projecthydra/orgs","repos_url":"https://api.github.com/users/projecthydra/repos","events_url":"https://api.github.com/users/projecthydra/events{/privacy}","received_events_url":"https://api.github.com/users/projecthydra/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/projecthydra/sufia","description":"Sufia extends the robust Hydra framework to provide a user interface around common repository features and social features. Sufia offers self-deposit and proxy deposit workflows with plans to develop one or more mediated deposit workflows in 2016. Sufia delivers its rich and growing set of features via a modern, responsive UI.","fork":false,"url":"https://api.github.com/repos/projecthydra/sufia","forks_url":"https://api.github.com/repos/projecthydra/sufia/forks","keys_url":"https://api.github.com/repos/projecthydra/sufia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/projecthydra/sufia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/projecthydra/sufia/teams","hooks_url":"https://api.github.com/repos/projecthydra/sufia/hooks","issue_events_url":"https://api.github.com/repos/projecthydra/sufia/issues/events{/number}","events_url":"https://api.github.com/repos/projecthydra/sufia/events","assignees_url":"https://api.github.com/repos/projecthydra/sufia/assignees{/user}","branches_url":"https://api.github.com/repos/projecthydra/sufia/branches{/branch}","tags_url":"https://api.github.com/repos/projecthydra/sufia/tags","blobs_url":"https://api.github.com/repos/projecthydra/sufia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/projecthydra/sufia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/projecthydra/sufia/git/refs{/sha}","trees_url":"https://api.github.com/repos/projecthydra/sufia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/projecthydra/sufia/statuses/{sha}","languages_url":"https://api.github.com/repos/projecthydra/sufia/languages","stargazers_url":"https://api.github.com/repos/projecthydra/sufia/stargazers","contributors_url":"https://api.github.com/repos/projecthydra/sufia/contributors","subscribers_url":"https://api.github.com/repos/projecthydra/sufia/subscribers","subscription_url":"https://api.github.com/repos/projecthydra/sufia/subscription","commits_url":"https://api.github.com/repos/projecthydra/sufia/commits{/sha}","git_commits_url":"https://api.github.com/repos/projecthydra/sufia/git/commits{/sha}","comments_url":"https://api.github.com/repos/projecthydra/sufia/comments{/number}","issue_comment_url":"https://api.github.com/repos/projecthydra/sufia/issues/comments{/number}","contents_url":"https://api.github.com/repos/projecthydra/sufia/contents/{+path}","compare_url":"https://api.github.com/repos/projecthydra/sufia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/projecthydra/sufia/merges","archive_url":"https://api.github.com/repos/projecthydra/sufia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/projecthydra/sufia/downloads","issues_url":"https://api.github.com/repos/projecthydra/sufia/issues{/number}","pulls_url":"https://api.github.com/repos/projecthydra/sufia/pulls{/number}","milestones_url":"https://api.github.com/repos/projecthydra/sufia/milestones{/number}","notifications_url":"https://api.github.com/repos/projecthydra/sufia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/projecthydra/sufia/labels{/name}","releases_url":"https://api.github.com/repos/projecthydra/sufia/releases{/id}","deployments_url":"https://api.github.com/repos/projecthydra/sufia/deployments","created_at":"2013-01-16T20:23:18Z","updated_at":"2016-01-25T17:45:10Z","pushed_at":"2016-02-11T20:22:35Z","git_url":"git://github.com/projecthydra/sufia.git","ssh_url":"git@github.com:projecthydra/sufia.git","clone_url":"https://github.com/projecthydra/sufia.git","svn_url":"https://github.com/projecthydra/sufia","homepage":"http://sufia.io/","size":54645,"stargazers_count":86,"watchers_count":86,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":68,"mirror_url":null,"open_issues_count":64,"forks":68,"open_issues":64,"watchers":86,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/1564"},"html":{"href":"https://github.com/projecthydra/sufia/pull/1564"},"issue":{"href":"https://api.github.com/repos/projecthydra/sufia/issues/1564"},"comments":{"href":"https://api.github.com/repos/projecthydra/sufia/issues/1564/comments"},"review_comments":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/1564/comments"},"review_comment":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/1564/commits"},"statuses":{"href":"https://api.github.com/repos/projecthydra/sufia/statuses/bcc1f87b124a11852e51c8a50be37b4e97d4b460"}}}}