{"action":"created","comment":{"url":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/comments/181537167","pull_request_review_id":112192127,"id":181537167,"diff_hunk":"@@ -0,0 +1,98 @@\n+# generates text for a report on storage root size and object status\n+class StatsReporter\n+\n+  require 'text-table'\n+  require 'open3'\n+\n+  def self.storage_report_text\n+    head = %w[filesystem total used pct_used free pct_free]\n+    Text::Table.new(head: head, rows: storage_report_lines).to_s\n+  end\n+\n+  def workflow_report_text\n+    head = %w[workflow waiting error recent archived]\n+    Text::Table.new(head: head, rows: workflow_report_lines).to_s\n+  end\n+\n+  def self.workflow_xml\n+    File.open('config/workflows/sdr/preservationIngestWF') { |f| Nokogiri::XML(f) }\n+  end\n+\n+  def self.repository\n+    workflow_xml.at_xpath('//workflow-def/@repository').value\n+  end\n+\n+  def self.ingest_wf\n+    workflow_xml.at_xpath('//workflow-def/@id').value\n+  end\n+\n+  def self.ingest_wf_steps\n+    workflow_xml.xpath('//process/@name').map(&:value)\n+  end\n+\n+  def self.df_output\n+    stdout_str, _status = Open3.capture2('df -h')\n+    stdout_str\n+  end\n+\n+  def self.storage_mount_lines\n+    df_output.split(\"\\n\").select { |line| line.include?('services-disk') }\n+  end\n+\n+  def self.parsed_storage_mount_lines\n+    storage_mount_lines.map do |line|\n+      storage_root = {}","path":"lib/stats_reporter.rb","position":44,"original_position":44,"commit_id":"79dacd07b57b964f6471e483350aecab4e7de852","original_commit_id":"79dacd07b57b964f6471e483350aecab4e7de852","user":{"login":"atz","id":109954,"avatar_url":"https://avatars2.githubusercontent.com/u/109954?v=4","gravatar_id":"","url":"https://api.github.com/users/atz","html_url":"https://github.com/atz","followers_url":"https://api.github.com/users/atz/followers","following_url":"https://api.github.com/users/atz/following{/other_user}","gists_url":"https://api.github.com/users/atz/gists{/gist_id}","starred_url":"https://api.github.com/users/atz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atz/subscriptions","organizations_url":"https://api.github.com/users/atz/orgs","repos_url":"https://api.github.com/users/atz/repos","events_url":"https://api.github.com/users/atz/events{/privacy}","received_events_url":"https://api.github.com/users/atz/received_events","type":"User","site_admin":false},"body":"My example above can be further refined to a single line:\r\n```ruby\r\nstorage_root = [:total, :used, :remaining, :percent_used, :filesystem].zip(split_line[0..4]).to_h\r\n```","created_at":"2018-04-14T01:29:48Z","updated_at":"2018-04-14T01:29:48Z","html_url":"https://github.com/sul-dlss/preservation_robots/pull/52#discussion_r181537167","pull_request_url":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/52","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/comments/181537167"},"html":{"href":"https://github.com/sul-dlss/preservation_robots/pull/52#discussion_r181537167"},"pull_request":{"href":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/52"}},"in_reply_to_id":181535525},"pull_request":{"url":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/52","id":181052654,"html_url":"https://github.com/sul-dlss/preservation_robots/pull/52","diff_url":"https://github.com/sul-dlss/preservation_robots/pull/52.diff","patch_url":"https://github.com/sul-dlss/preservation_robots/pull/52.patch","issue_url":"https://api.github.com/repos/sul-dlss/preservation_robots/issues/52","number":52,"state":"open","locked":false,"title":"Rewrite sdr-preservation-core weekly-stats","user":{"login":"tallenaz","id":97104,"avatar_url":"https://avatars0.githubusercontent.com/u/97104?v=4","gravatar_id":"","url":"https://api.github.com/users/tallenaz","html_url":"https://github.com/tallenaz","followers_url":"https://api.github.com/users/tallenaz/followers","following_url":"https://api.github.com/users/tallenaz/following{/other_user}","gists_url":"https://api.github.com/users/tallenaz/gists{/gist_id}","starred_url":"https://api.github.com/users/tallenaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tallenaz/subscriptions","organizations_url":"https://api.github.com/users/tallenaz/orgs","repos_url":"https://api.github.com/users/tallenaz/repos","events_url":"https://api.github.com/users/tallenaz/events{/privacy}","received_events_url":"https://api.github.com/users/tallenaz/received_events","type":"User","site_admin":false},"body":"Paired with @jmartin-sul on specs\r\n\r\n- add certs dir to gitignore, and modify settings to make querying workflow from your laptop easier\r\n- add some gem dependencies, for reasons commented in `Gemfile`\r\n- add bin script to generate the report (punting on a whenever task to send it out to the right folks)\r\n- add `stats_reporter` class to generate text for the bin script\r\n- add tests for formerly untested code!\r\n\r\nOne concern is that because the workflow and steps have changed, I'm not 100% certain that the `waiting_count` and `completed_count` methods will return what we want, but I commented as such, and took my best guess.\r\n\r\nFixes #24 ","created_at":"2018-04-11T23:17:04Z","updated_at":"2018-04-14T01:29:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b2224d3ec673f342779e1a15b7bb3d15bf62cc38","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":845598715,"url":"https://api.github.com/repos/sul-dlss/preservation_robots/labels/needs%20review","name":"needs review","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/52/commits","review_comments_url":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/52/comments","review_comment_url":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sul-dlss/preservation_robots/issues/52/comments","statuses_url":"https://api.github.com/repos/sul-dlss/preservation_robots/statuses/79dacd07b57b964f6471e483350aecab4e7de852","head":{"label":"sul-dlss:azanellaStatsStorage","ref":"azanellaStatsStorage","sha":"79dacd07b57b964f6471e483350aecab4e7de852","user":{"login":"sul-dlss","id":230583,"avatar_url":"https://avatars1.githubusercontent.com/u/230583?v=4","gravatar_id":"","url":"https://api.github.com/users/sul-dlss","html_url":"https://github.com/sul-dlss","followers_url":"https://api.github.com/users/sul-dlss/followers","following_url":"https://api.github.com/users/sul-dlss/following{/other_user}","gists_url":"https://api.github.com/users/sul-dlss/gists{/gist_id}","starred_url":"https://api.github.com/users/sul-dlss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sul-dlss/subscriptions","organizations_url":"https://api.github.com/users/sul-dlss/orgs","repos_url":"https://api.github.com/users/sul-dlss/repos","events_url":"https://api.github.com/users/sul-dlss/events{/privacy}","received_events_url":"https://api.github.com/users/sul-dlss/received_events","type":"Organization","site_admin":false},"repo":{"id":122419380,"name":"preservation_robots","full_name":"sul-dlss/preservation_robots","owner":{"login":"sul-dlss","id":230583,"avatar_url":"https://avatars1.githubusercontent.com/u/230583?v=4","gravatar_id":"","url":"https://api.github.com/users/sul-dlss","html_url":"https://github.com/sul-dlss","followers_url":"https://api.github.com/users/sul-dlss/followers","following_url":"https://api.github.com/users/sul-dlss/following{/other_user}","gists_url":"https://api.github.com/users/sul-dlss/gists{/gist_id}","starred_url":"https://api.github.com/users/sul-dlss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sul-dlss/subscriptions","organizations_url":"https://api.github.com/users/sul-dlss/orgs","repos_url":"https://api.github.com/users/sul-dlss/repos","events_url":"https://api.github.com/users/sul-dlss/events{/privacy}","received_events_url":"https://api.github.com/users/sul-dlss/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sul-dlss/preservation_robots","description":"Robots for creating/updating Moabs for SDR objects, adding Moabs to the preservation_catalog, etc.","fork":false,"url":"https://api.github.com/repos/sul-dlss/preservation_robots","forks_url":"https://api.github.com/repos/sul-dlss/preservation_robots/forks","keys_url":"https://api.github.com/repos/sul-dlss/preservation_robots/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sul-dlss/preservation_robots/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sul-dlss/preservation_robots/teams","hooks_url":"https://api.github.com/repos/sul-dlss/preservation_robots/hooks","issue_events_url":"https://api.github.com/repos/sul-dlss/preservation_robots/issues/events{/number}","events_url":"https://api.github.com/repos/sul-dlss/preservation_robots/events","assignees_url":"https://api.github.com/repos/sul-dlss/preservation_robots/assignees{/user}","branches_url":"https://api.github.com/repos/sul-dlss/preservation_robots/branches{/branch}","tags_url":"https://api.github.com/repos/sul-dlss/preservation_robots/tags","blobs_url":"https://api.github.com/repos/sul-dlss/preservation_robots/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sul-dlss/preservation_robots/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sul-dlss/preservation_robots/git/refs{/sha}","trees_url":"https://api.github.com/repos/sul-dlss/preservation_robots/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sul-dlss/preservation_robots/statuses/{sha}","languages_url":"https://api.github.com/repos/sul-dlss/preservation_robots/languages","stargazers_url":"https://api.github.com/repos/sul-dlss/preservation_robots/stargazers","contributors_url":"https://api.github.com/repos/sul-dlss/preservation_robots/contributors","subscribers_url":"https://api.github.com/repos/sul-dlss/preservation_robots/subscribers","subscription_url":"https://api.github.com/repos/sul-dlss/preservation_robots/subscription","commits_url":"https://api.github.com/repos/sul-dlss/preservation_robots/commits{/sha}","git_commits_url":"https://api.github.com/repos/sul-dlss/preservation_robots/git/commits{/sha}","comments_url":"https://api.github.com/repos/sul-dlss/preservation_robots/comments{/number}","issue_comment_url":"https://api.github.com/repos/sul-dlss/preservation_robots/issues/comments{/number}","contents_url":"https://api.github.com/repos/sul-dlss/preservation_robots/contents/{+path}","compare_url":"https://api.github.com/repos/sul-dlss/preservation_robots/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sul-dlss/preservation_robots/merges","archive_url":"https://api.github.com/repos/sul-dlss/preservation_robots/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sul-dlss/preservation_robots/downloads","issues_url":"https://api.github.com/repos/sul-dlss/preservation_robots/issues{/number}","pulls_url":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls{/number}","milestones_url":"https://api.github.com/repos/sul-dlss/preservation_robots/milestones{/number}","notifications_url":"https://api.github.com/repos/sul-dlss/preservation_robots/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sul-dlss/preservation_robots/labels{/name}","releases_url":"https://api.github.com/repos/sul-dlss/preservation_robots/releases{/id}","deployments_url":"https://api.github.com/repos/sul-dlss/preservation_robots/deployments","created_at":"2018-02-22T02:12:19Z","updated_at":"2018-04-11T04:59:26Z","pushed_at":"2018-04-13T23:13:10Z","git_url":"git://github.com/sul-dlss/preservation_robots.git","ssh_url":"git@github.com:sul-dlss/preservation_robots.git","clone_url":"https://github.com/sul-dlss/preservation_robots.git","svn_url":"https://github.com/sul-dlss/preservation_robots","homepage":null,"size":140,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":18,"watchers":0,"default_branch":"master"}},"base":{"label":"sul-dlss:master","ref":"master","sha":"fa91e5097b66c66557a9da8a99a4ad6163b9b3f3","user":{"login":"sul-dlss","id":230583,"avatar_url":"https://avatars1.githubusercontent.com/u/230583?v=4","gravatar_id":"","url":"https://api.github.com/users/sul-dlss","html_url":"https://github.com/sul-dlss","followers_url":"https://api.github.com/users/sul-dlss/followers","following_url":"https://api.github.com/users/sul-dlss/following{/other_user}","gists_url":"https://api.github.com/users/sul-dlss/gists{/gist_id}","starred_url":"https://api.github.com/users/sul-dlss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sul-dlss/subscriptions","organizations_url":"https://api.github.com/users/sul-dlss/orgs","repos_url":"https://api.github.com/users/sul-dlss/repos","events_url":"https://api.github.com/users/sul-dlss/events{/privacy}","received_events_url":"https://api.github.com/users/sul-dlss/received_events","type":"Organization","site_admin":false},"repo":{"id":122419380,"name":"preservation_robots","full_name":"sul-dlss/preservation_robots","owner":{"login":"sul-dlss","id":230583,"avatar_url":"https://avatars1.githubusercontent.com/u/230583?v=4","gravatar_id":"","url":"https://api.github.com/users/sul-dlss","html_url":"https://github.com/sul-dlss","followers_url":"https://api.github.com/users/sul-dlss/followers","following_url":"https://api.github.com/users/sul-dlss/following{/other_user}","gists_url":"https://api.github.com/users/sul-dlss/gists{/gist_id}","starred_url":"https://api.github.com/users/sul-dlss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sul-dlss/subscriptions","organizations_url":"https://api.github.com/users/sul-dlss/orgs","repos_url":"https://api.github.com/users/sul-dlss/repos","events_url":"https://api.github.com/users/sul-dlss/events{/privacy}","received_events_url":"https://api.github.com/users/sul-dlss/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sul-dlss/preservation_robots","description":"Robots for creating/updating Moabs for SDR objects, adding Moabs to the preservation_catalog, etc.","fork":false,"url":"https://api.github.com/repos/sul-dlss/preservation_robots","forks_url":"https://api.github.com/repos/sul-dlss/preservation_robots/forks","keys_url":"https://api.github.com/repos/sul-dlss/preservation_robots/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sul-dlss/preservation_robots/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sul-dlss/preservation_robots/teams","hooks_url":"https://api.github.com/repos/sul-dlss/preservation_robots/hooks","issue_events_url":"https://api.github.com/repos/sul-dlss/preservation_robots/issues/events{/number}","events_url":"https://api.github.com/repos/sul-dlss/preservation_robots/events","assignees_url":"https://api.github.com/repos/sul-dlss/preservation_robots/assignees{/user}","branches_url":"https://api.github.com/repos/sul-dlss/preservation_robots/branches{/branch}","tags_url":"https://api.github.com/repos/sul-dlss/preservation_robots/tags","blobs_url":"https://api.github.com/repos/sul-dlss/preservation_robots/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sul-dlss/preservation_robots/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sul-dlss/preservation_robots/git/refs{/sha}","trees_url":"https://api.github.com/repos/sul-dlss/preservation_robots/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sul-dlss/preservation_robots/statuses/{sha}","languages_url":"https://api.github.com/repos/sul-dlss/preservation_robots/languages","stargazers_url":"https://api.github.com/repos/sul-dlss/preservation_robots/stargazers","contributors_url":"https://api.github.com/repos/sul-dlss/preservation_robots/contributors","subscribers_url":"https://api.github.com/repos/sul-dlss/preservation_robots/subscribers","subscription_url":"https://api.github.com/repos/sul-dlss/preservation_robots/subscription","commits_url":"https://api.github.com/repos/sul-dlss/preservation_robots/commits{/sha}","git_commits_url":"https://api.github.com/repos/sul-dlss/preservation_robots/git/commits{/sha}","comments_url":"https://api.github.com/repos/sul-dlss/preservation_robots/comments{/number}","issue_comment_url":"https://api.github.com/repos/sul-dlss/preservation_robots/issues/comments{/number}","contents_url":"https://api.github.com/repos/sul-dlss/preservation_robots/contents/{+path}","compare_url":"https://api.github.com/repos/sul-dlss/preservation_robots/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sul-dlss/preservation_robots/merges","archive_url":"https://api.github.com/repos/sul-dlss/preservation_robots/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sul-dlss/preservation_robots/downloads","issues_url":"https://api.github.com/repos/sul-dlss/preservation_robots/issues{/number}","pulls_url":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls{/number}","milestones_url":"https://api.github.com/repos/sul-dlss/preservation_robots/milestones{/number}","notifications_url":"https://api.github.com/repos/sul-dlss/preservation_robots/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sul-dlss/preservation_robots/labels{/name}","releases_url":"https://api.github.com/repos/sul-dlss/preservation_robots/releases{/id}","deployments_url":"https://api.github.com/repos/sul-dlss/preservation_robots/deployments","created_at":"2018-02-22T02:12:19Z","updated_at":"2018-04-11T04:59:26Z","pushed_at":"2018-04-13T23:13:10Z","git_url":"git://github.com/sul-dlss/preservation_robots.git","ssh_url":"git@github.com:sul-dlss/preservation_robots.git","clone_url":"https://github.com/sul-dlss/preservation_robots.git","svn_url":"https://github.com/sul-dlss/preservation_robots","homepage":null,"size":140,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":18,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/52"},"html":{"href":"https://github.com/sul-dlss/preservation_robots/pull/52"},"issue":{"href":"https://api.github.com/repos/sul-dlss/preservation_robots/issues/52"},"comments":{"href":"https://api.github.com/repos/sul-dlss/preservation_robots/issues/52/comments"},"review_comments":{"href":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/52/comments"},"review_comment":{"href":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sul-dlss/preservation_robots/pulls/52/commits"},"statuses":{"href":"https://api.github.com/repos/sul-dlss/preservation_robots/statuses/79dacd07b57b964f6471e483350aecab4e7de852"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"atz"}}