{"action":"created","comment":{"url":"https://api.github.com/repos/projecthydra/sufia/pulls/comments/31831206","id":31831206,"diff_hunk":"@@ -0,0 +1,86 @@\n+require 'spec_helper'\n+\n+describe Admin::StatsController, type: :controller do\n+  let(:user1) { FactoryGirl.find_or_create(:user) }\n+  let(:user2) { FactoryGirl.find_or_create(:archivist) }\n+  \n+  before do\n+    allow(user1).to receive(:groups).and_return(['umg/up.dlt.scholarsphere-admin-viewers'])\n+    allow(user2).to receive(:groups).and_return(['umg/up.dlt.some-other-group'])\n+  end\n+\n+  describe \"statistics page\" do\n+    render_views\n+    before do\n+      sign_in user1\n+    end\n+\n+    it 'allows an authorized user to view the page' do\n+      get :index\n+      expect(response).to be_success\n+      expect(response.body).to include('Statistics for Blacklight')\n+      expect(response.body).to include('Total Blacklight Users')\n+    end\n+\n+    describe \"querying user_stats\" do\n+      it \"defaults to latest 5 users\" do\n+        get :index\n+        expect(assigns[:recent_users]).to eq(User.order('created_at DESC').limit(5))\n+      end\n+      it \"allows queries against user_stats\" do\n+        expect(User).to receive(:where).with('id' => user1.id).once.and_return([user1])\n+        expect(User).to receive(:where).with('created_at >= ?',  1.days.ago.strftime(\"%Y-%m-%d\")).and_return([user2])\n+        get :index, users_stats: {start_date:1.days.ago.strftime(\"%Y-%m-%d\")}\n+        expect(assigns[:recent_users]).to eq([user2])\n+      end\n+    end\n+\n+    describe \"files_count\" do\n+      let(:original_files_count) do\n+        poltergeist = GenericFile.new\n+        poltergeist.apply_depositor_metadata(user1)\n+        poltergeist.save\n+        original_files_count = GenericFile.count\n+        ActiveFedora::SolrService.instance.conn.delete_by_id(poltergeist.id)\n+        original_files_count\n+      end\n+      it \"should provide accurate files_count, ensuring that solr deletes have been expunged first\" do\n+        get :index\n+        expect(assigns[:files_count][:total]).to eq(original_files_count - 1)\n+      end\n+    end\n+\n+    describe \"counts\" do\n+      before do\n+        GenericFile.new.tap do |f|\n+          f.apply_depositor_metadata(user1.user_key)\n+          f.save\n+        end\n+        GenericFile.new.tap do |f|","path":"spec/controllers/admin_stats_controller_spec.rb","position":59,"original_position":59,"commit_id":"9fe5bc3bdb2760087017b5fe60cc0484d9fbeb3f","original_commit_id":"9fe5bc3bdb2760087017b5fe60cc0484d9fbeb3f","user":{"login":"mjgiarlo","id":131982,"avatar_url":"https://avatars.githubusercontent.com/u/131982?v=3","gravatar_id":"","url":"https://api.github.com/users/mjgiarlo","html_url":"https://github.com/mjgiarlo","followers_url":"https://api.github.com/users/mjgiarlo/followers","following_url":"https://api.github.com/users/mjgiarlo/following{/other_user}","gists_url":"https://api.github.com/users/mjgiarlo/gists{/gist_id}","starred_url":"https://api.github.com/users/mjgiarlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjgiarlo/subscriptions","organizations_url":"https://api.github.com/users/mjgiarlo/orgs","repos_url":"https://api.github.com/users/mjgiarlo/repos","events_url":"https://api.github.com/users/mjgiarlo/events{/privacy}","received_events_url":"https://api.github.com/users/mjgiarlo/received_events","type":"User","site_admin":false},"body":"Simplify to \r\n\r\n```ruby\r\nGenericFile.create(read_groups = ['public']) do |f|\r\n  f.apply_depositor_metadata(user1.user_key)\r\nend\r\n```","created_at":"2015-06-05T17:05:23Z","updated_at":"2015-06-05T17:05:23Z","html_url":"https://github.com/projecthydra/sufia/pull/1181#discussion_r31831206","pull_request_url":"https://api.github.com/repos/projecthydra/sufia/pulls/1181","_links":{"self":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/comments/31831206"},"html":{"href":"https://github.com/projecthydra/sufia/pull/1181#discussion_r31831206"},"pull_request":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/1181"}}},"pull_request":{"url":"https://api.github.com/repos/projecthydra/sufia/pulls/1181","id":37042990,"html_url":"https://github.com/projecthydra/sufia/pull/1181","diff_url":"https://github.com/projecthydra/sufia/pull/1181.diff","patch_url":"https://github.com/projecthydra/sufia/pull/1181.patch","issue_url":"https://api.github.com/repos/projecthydra/sufia/issues/1181","number":1181,"state":"open","locked":false,"title":"Adding admin stats to sufia by copying them from ScholarSphere","user":{"login":"cam156","id":1599081,"avatar_url":"https://avatars.githubusercontent.com/u/1599081?v=3","gravatar_id":"","url":"https://api.github.com/users/cam156","html_url":"https://github.com/cam156","followers_url":"https://api.github.com/users/cam156/followers","following_url":"https://api.github.com/users/cam156/following{/other_user}","gists_url":"https://api.github.com/users/cam156/gists{/gist_id}","starred_url":"https://api.github.com/users/cam156/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cam156/subscriptions","organizations_url":"https://api.github.com/users/cam156/orgs","repos_url":"https://api.github.com/users/cam156/repos","events_url":"https://api.github.com/users/cam156/events{/privacy}","received_events_url":"https://api.github.com/users/cam156/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-05T15:38:21Z","updated_at":"2015-06-05T17:05:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b2db431ccdf985c413a11b23315a1b0875430f31","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/projecthydra/sufia/pulls/1181/commits","review_comments_url":"https://api.github.com/repos/projecthydra/sufia/pulls/1181/comments","review_comment_url":"https://api.github.com/repos/projecthydra/sufia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/projecthydra/sufia/issues/1181/comments","statuses_url":"https://api.github.com/repos/projecthydra/sufia/statuses/9fe5bc3bdb2760087017b5fe60cc0484d9fbeb3f","head":{"label":"psu-stewardship:admin_stats","ref":"admin_stats","sha":"9fe5bc3bdb2760087017b5fe60cc0484d9fbeb3f","user":{"login":"psu-stewardship","id":653493,"avatar_url":"https://avatars.githubusercontent.com/u/653493?v=3","gravatar_id":"","url":"https://api.github.com/users/psu-stewardship","html_url":"https://github.com/psu-stewardship","followers_url":"https://api.github.com/users/psu-stewardship/followers","following_url":"https://api.github.com/users/psu-stewardship/following{/other_user}","gists_url":"https://api.github.com/users/psu-stewardship/gists{/gist_id}","starred_url":"https://api.github.com/users/psu-stewardship/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/psu-stewardship/subscriptions","organizations_url":"https://api.github.com/users/psu-stewardship/orgs","repos_url":"https://api.github.com/users/psu-stewardship/repos","events_url":"https://api.github.com/users/psu-stewardship/events{/privacy}","received_events_url":"https://api.github.com/users/psu-stewardship/received_events","type":"Organization","site_admin":false},"repo":{"id":7669277,"name":"sufia","full_name":"psu-stewardship/sufia","owner":{"login":"psu-stewardship","id":653493,"avatar_url":"https://avatars.githubusercontent.com/u/653493?v=3","gravatar_id":"","url":"https://api.github.com/users/psu-stewardship","html_url":"https://github.com/psu-stewardship","followers_url":"https://api.github.com/users/psu-stewardship/followers","following_url":"https://api.github.com/users/psu-stewardship/following{/other_user}","gists_url":"https://api.github.com/users/psu-stewardship/gists{/gist_id}","starred_url":"https://api.github.com/users/psu-stewardship/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/psu-stewardship/subscriptions","organizations_url":"https://api.github.com/users/psu-stewardship/orgs","repos_url":"https://api.github.com/users/psu-stewardship/repos","events_url":"https://api.github.com/users/psu-stewardship/events{/privacy}","received_events_url":"https://api.github.com/users/psu-stewardship/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/psu-stewardship/sufia","description":"Sufia is a Rails engine for creating a self-deposit institutional repository. A web application for ingest, curation, search, and display of digital assets. Powered by Hydra technologies (Rails, Hydra-head, Blacklight, Solr, Fedora Commons, etc.)","fork":true,"url":"https://api.github.com/repos/psu-stewardship/sufia","forks_url":"https://api.github.com/repos/psu-stewardship/sufia/forks","keys_url":"https://api.github.com/repos/psu-stewardship/sufia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/psu-stewardship/sufia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/psu-stewardship/sufia/teams","hooks_url":"https://api.github.com/repos/psu-stewardship/sufia/hooks","issue_events_url":"https://api.github.com/repos/psu-stewardship/sufia/issues/events{/number}","events_url":"https://api.github.com/repos/psu-stewardship/sufia/events","assignees_url":"https://api.github.com/repos/psu-stewardship/sufia/assignees{/user}","branches_url":"https://api.github.com/repos/psu-stewardship/sufia/branches{/branch}","tags_url":"https://api.github.com/repos/psu-stewardship/sufia/tags","blobs_url":"https://api.github.com/repos/psu-stewardship/sufia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/psu-stewardship/sufia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/psu-stewardship/sufia/git/refs{/sha}","trees_url":"https://api.github.com/repos/psu-stewardship/sufia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/psu-stewardship/sufia/statuses/{sha}","languages_url":"https://api.github.com/repos/psu-stewardship/sufia/languages","stargazers_url":"https://api.github.com/repos/psu-stewardship/sufia/stargazers","contributors_url":"https://api.github.com/repos/psu-stewardship/sufia/contributors","subscribers_url":"https://api.github.com/repos/psu-stewardship/sufia/subscribers","subscription_url":"https://api.github.com/repos/psu-stewardship/sufia/subscription","commits_url":"https://api.github.com/repos/psu-stewardship/sufia/commits{/sha}","git_commits_url":"https://api.github.com/repos/psu-stewardship/sufia/git/commits{/sha}","comments_url":"https://api.github.com/repos/psu-stewardship/sufia/comments{/number}","issue_comment_url":"https://api.github.com/repos/psu-stewardship/sufia/issues/comments{/number}","contents_url":"https://api.github.com/repos/psu-stewardship/sufia/contents/{+path}","compare_url":"https://api.github.com/repos/psu-stewardship/sufia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/psu-stewardship/sufia/merges","archive_url":"https://api.github.com/repos/psu-stewardship/sufia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/psu-stewardship/sufia/downloads","issues_url":"https://api.github.com/repos/psu-stewardship/sufia/issues{/number}","pulls_url":"https://api.github.com/repos/psu-stewardship/sufia/pulls{/number}","milestones_url":"https://api.github.com/repos/psu-stewardship/sufia/milestones{/number}","notifications_url":"https://api.github.com/repos/psu-stewardship/sufia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/psu-stewardship/sufia/labels{/name}","releases_url":"https://api.github.com/repos/psu-stewardship/sufia/releases{/id}","created_at":"2013-01-17T16:04:18Z","updated_at":"2015-04-23T16:51:08Z","pushed_at":"2015-06-05T14:18:56Z","git_url":"git://github.com/psu-stewardship/sufia.git","ssh_url":"git@github.com:psu-stewardship/sufia.git","clone_url":"https://github.com/psu-stewardship/sufia.git","svn_url":"https://github.com/psu-stewardship/sufia","homepage":"","size":55601,"stargazers_count":3,"watchers_count":3,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"projecthydra:master","ref":"master","sha":"4392773a05691497ed06a1219a502ca9c9436611","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 is a Rails engine for creating a self-deposit institutional repository. A web application for ingest, curation, search, and display of digital assets. Powered by Hydra technologies (Rails, Hydra-head, Blacklight, Solr, Fedora Commons, etc.)","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}","created_at":"2013-01-16T20:23:18Z","updated_at":"2015-05-29T13:57:54Z","pushed_at":"2015-06-05T15:38:21Z","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":"","size":62835,"stargazers_count":62,"watchers_count":62,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":54,"mirror_url":null,"open_issues_count":93,"forks":54,"open_issues":93,"watchers":62,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/1181"},"html":{"href":"https://github.com/projecthydra/sufia/pull/1181"},"issue":{"href":"https://api.github.com/repos/projecthydra/sufia/issues/1181"},"comments":{"href":"https://api.github.com/repos/projecthydra/sufia/issues/1181/comments"},"review_comments":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/1181/comments"},"review_comment":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/projecthydra/sufia/pulls/1181/commits"},"statuses":{"href":"https://api.github.com/repos/projecthydra/sufia/statuses/9fe5bc3bdb2760087017b5fe60cc0484d9fbeb3f"}}}}