{"action":"created","issue":{"url":"https://api.github.com/repos/enterprisemediawiki/meza/issues/418","repository_url":"https://api.github.com/repos/enterprisemediawiki/meza","labels_url":"https://api.github.com/repos/enterprisemediawiki/meza/issues/418/labels{/name}","comments_url":"https://api.github.com/repos/enterprisemediawiki/meza/issues/418/comments","events_url":"https://api.github.com/repos/enterprisemediawiki/meza/issues/418/events","html_url":"https://github.com/enterprisemediawiki/meza/issues/418","id":165708646,"number":418,"title":"Report delinquent ApprovedRevs pages","user":{"login":"darenwelsh","id":6728676,"avatar_url":"https://avatars.githubusercontent.com/u/6728676?v=3","gravatar_id":"","url":"https://api.github.com/users/darenwelsh","html_url":"https://github.com/darenwelsh","followers_url":"https://api.github.com/users/darenwelsh/followers","following_url":"https://api.github.com/users/darenwelsh/following{/other_user}","gists_url":"https://api.github.com/users/darenwelsh/gists{/gist_id}","starred_url":"https://api.github.com/users/darenwelsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darenwelsh/subscriptions","organizations_url":"https://api.github.com/users/darenwelsh/orgs","repos_url":"https://api.github.com/users/darenwelsh/repos","events_url":"https://api.github.com/users/darenwelsh/events{/privacy}","received_events_url":"https://api.github.com/users/darenwelsh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-15T04:21:51Z","updated_at":"2016-07-17T00:24:45Z","closed_at":null,"body":"I made a scheduled task that runs a script every Monday at 2 PM to report which ApprovedRevs pages have unapproved revisions (sorted in order by worst-offender chronologically). We might use this to prod the group to review these revisions and approve or modify as required, all to help keep our “important” pages current.\r\n\r\nI'm not sure this belongs in this repo, but I'm saving it here until I figure out where to put it (since it makes use of a couple meza files).\r\n\r\n```\r\n#!/bin/bash\r\n#\r\n# delinquent-approved-revs-report.sh\r\n#\r\n# Send an announcement to Slack reporting delinquent approved-revs pages and files\r\n#\r\n\r\n\r\n\r\nif [ \"$(whoami)\" != \"root\" ]; then\r\n\techo \"Try running this script with sudo: \\\"sudo bash backup-remote-wikis.sh\\\"\"\r\n\texit 1\r\nfi\r\n\r\n# If /usr/local/bin is not in PATH then add it\r\n# Ref enterprisemediawiki/meza#68 \"Run install.sh with non-root user\"\r\nif [[ $PATH != *\"/usr/local/bin\"* ]]; then\r\n\tPATH=\"/usr/local/bin:$PATH\"\r\nfi\r\n\r\nsource /opt/meza/config/core/config.sh\r\n\r\nif [ -f \"/opt/meza/config/local/remote-wiki-config.sh\" ]; then\r\n\tsource \"/opt/meza/config/local/remote-wiki-config.sh\"\r\nfi\r\n\r\n# SQL query\r\nquery=\"SET group_concat_max_len = 2048; SELECT GROUP_CONCAT( CONCAT(date_format(rev_timestamp, '%Y-%m-%d'),':  ',page_title) ORDER BY rev_timestamp ASC SEPARATOR '@') AS Date_Page FROM (SELECT page_id, approvedrevs.rev_id, rev_timestamp FROM (SELECT page_id, rev_id FROM approved_revs )approvedrevs JOIN (SELECT rev_parent_id, rev_timestamp FROM revision )revision ON approvedrevs.rev_id = revision.rev_parent_id )pages JOIN (SELECT page_id, page_namespace, page_title FROM page )page ON page.page_id = pages.page_id ORDER BY rev_timestamp ASC\"\r\n\r\n# Obtain report via mysql query\r\nreport=$(echo $query | mysql -N wiki_eva --user=root --password=$mysql_root_pass)\r\n\r\n# Replace underscores with spaces\r\nreport=${report//_/ }\r\nreport=${report//@/'\\n'}\r\n\r\n# replace amphersand with URL encoding\r\nreport=${report//&/%26amp}\r\n\r\n# Use this webhook\r\nslackwebhook=\"<putyourwebhookhere>\"\r\n\r\nAnnounce completion of backup on Slack if a slack webhook provided\r\nif [[ ! -z \"$slackwebhook\" ]]; then\r\n\tbash \"/opt/meza/scripts/slack.sh\" \"$slackwebhook\" \"The following pages have revisions that have not been approved:\" \"${report}\"\r\n\r\nfi\r\n```"},"comment":{"url":"https://api.github.com/repos/enterprisemediawiki/meza/issues/comments/233158189","html_url":"https://github.com/enterprisemediawiki/meza/issues/418#issuecomment-233158189","issue_url":"https://api.github.com/repos/enterprisemediawiki/meza/issues/418","id":233158189,"user":{"login":"darenwelsh","id":6728676,"avatar_url":"https://avatars.githubusercontent.com/u/6728676?v=3","gravatar_id":"","url":"https://api.github.com/users/darenwelsh","html_url":"https://github.com/darenwelsh","followers_url":"https://api.github.com/users/darenwelsh/followers","following_url":"https://api.github.com/users/darenwelsh/following{/other_user}","gists_url":"https://api.github.com/users/darenwelsh/gists{/gist_id}","starred_url":"https://api.github.com/users/darenwelsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darenwelsh/subscriptions","organizations_url":"https://api.github.com/users/darenwelsh/orgs","repos_url":"https://api.github.com/users/darenwelsh/repos","events_url":"https://api.github.com/users/darenwelsh/events{/privacy}","received_events_url":"https://api.github.com/users/darenwelsh/received_events","type":"User","site_admin":false},"created_at":"2016-07-17T00:24:45Z","updated_at":"2016-07-17T00:24:45Z","body":"Now with more blame! For each page, it executes a SMW ask query for \"Lesson plan owner\" via api.php and appends the relevant names.\r\n\r\n```\r\n#!/bin/bash\r\n#\r\n# delinquent-approved-revs-report.sh\r\n#\r\n# Send an announcement to Slack reporting delinquent approved-revs pages and files\r\n#\r\n\r\nif [ \"$(whoami)\" != \"root\" ]; then\r\n\techo \"Try running this script with sudo: \\\"delinquent-approved-revs-report.sh\\\"\"\r\n\texit 1\r\nfi\r\n\r\n# If /usr/local/bin is not in PATH then add it\r\n# Ref enterprisemediawiki/meza#68 \"Run install.sh with non-root user\"\r\nif [[ $PATH != *\"/usr/local/bin\"* ]]; then\r\n\tPATH=\"/usr/local/bin:$PATH\"\r\nfi\r\n\r\nsource /opt/meza/config/core/config.sh\r\n\r\nif [ -f \"/opt/meza/config/local/remote-wiki-config.sh\" ]; then\r\n\tsource \"/opt/meza/config/local/remote-wiki-config.sh\"\r\nfi\r\n\r\n# Use this webhook\r\nslackwebhook=\"<webhook>\"\r\n\r\n# SQL query\r\nquery=\"SET group_concat_max_len = 2048; SELECT GROUP_CONCAT( CONCAT(date_format(rev_timestamp, '%Y-%m-%d'),' -- ',page_title) ORDER BY rev_timestamp ASC SEPARATOR '@') AS Date_Page FROM (SELECT page_id, approvedrevs.rev_id, rev_timestamp FROM (SELECT page_id, rev_id FROM approved_revs )approvedrevs JOIN (SELECT rev_parent_id, rev_timestamp FROM revision )revision ON approvedrevs.rev_id = revision.rev_parent_id )pages JOIN (SELECT page_id, page_namespace, page_title FROM page )page ON page.page_id = pages.page_id ORDER BY rev_timestamp ASC\"\r\n\r\n# Obtain report via mysql query\r\nreport=$(echo $query | mysql -N wiki_eva --user=root --password=$mysql_root_pass)\r\n\r\n# Replace underscores with spaces\r\nreport=${report//_/ }\r\n\r\n# replace amphersand with URL encoding\r\nreport=${report//&/%26}\r\n\r\n# Option 1: Use meza Slack script\r\n\r\n# Each page is separated by @\r\n# report=${report//@/'\\n'}\r\n\r\n# Announce completion of backup on Slack if a slack webhook provided\r\n# if [[ ! -z \"$slackwebhook\" ]]; then\r\n# \tbash \"/opt/meza/scripts/slack.sh\" \"$slackwebhook\" \"The following pages have revisions that have not been approved:\" \"${report}\"\r\n# fi\r\n\r\n# Option 2: Manually create json instead of using meza script\r\n\r\n# Each page is separated by @\r\n# report=${report//@/'\\n'}\r\n\r\n# json=\"{\r\n# \t    \\\"attachments\\\": [\r\n# \t        {\r\n# \t            \\\"color\\\": \\\"#339966\\\",\r\n# \t            \\\"fallback\\\": \\\"test\\\",\r\n# \t            \\\"fields\\\": [\r\n# \t                {\r\n# \t                    \\\"short\\\": false,\r\n# \t                    \\\"title\\\": \\\"Approved Revision pages with delinquent reviews:\\\",\r\n# \t                    \\\"value\\\": \\\"${report}\\\"\r\n# \t                }\r\n# \t            ]\r\n# \t        }\r\n# \t    ]\r\n# \t}\"\r\n#\r\n# curl -s -d \"payload=$json\" \"$slackwebhook\"\r\n\r\n\r\n# Option 3: Allows for loop to do additional functions on each page\r\n# Currently using this to query and list owners of each page\r\njson=\"{\r\n\t    \\\"attachments\\\": [\r\n\t        {\r\n\t            \\\"color\\\": \\\"#339966\\\",\r\n\t            \\\"fallback\\\": \\\"Approved Revs Report\\\",\r\n\t            \\\"fields\\\": [ {\r\n\t                    \\\"short\\\": false,\r\n\t                    \\\"title\\\": \\\"The following pages have revisions that have not been approved\\\",\r\n\t                    \\\"value\\\": \\\"The date represents the oldest unapproved revision. If the page has lesson plan owners, they are displayed below the page name.\\\"\r\n\t\t\t\t}, \"\r\n\r\nIFS='@' read -ra rep <<< \"$report\"\r\nfor i in \"${rep[@]}\"; do\r\n\r\n# Get \"Lesson plan owner\" for each page\r\n# Extract only the class name from \"2016-05-16 -- ISS EMU MAINT 1\"\r\nclassname=$(echo $i | sed 's/^.*-- //')\r\nclassname=${classname// /%20}\r\nurl=\"https://wiki.jsc.nasa.gov/eva/api.php?action=ask&query=[[$classname]]|%3FLesson%20plan%20owner&format=json\"\r\nowners=$(curl -g -k $url | grep -Po '(?<=\\{\"fulltext\":\")[^\"]*')\r\n\r\n\t# json=\"{\r\n\t#     \\\"attachments\\\": [\r\n\t#         {\r\n\t#             \\\"color\\\": \\\"#339966\\\",\r\n\t#             \\\"fallback\\\": \\\"test\\\",\r\n\t#             \\\"fields\\\": [\r\n\t\t            json=\"$json {\r\n\t                    \\\"short\\\": false,\r\n\t                    \\\"title\\\": \\\"$i\\\",\r\n\t                    \\\"value\\\": \\\"$owners\\\"\r\n\t                }, \"\r\n\t#             ]\r\n\t#         }\r\n\t#     ]\r\n\t# }\"\r\n\r\ndone\r\n\r\n\t\t\t\t\tjson=\"$json {\r\n\t                    \\\"short\\\": false,\r\n\t                    \\\"title\\\": \\\"\\\",\r\n\t                    \\\"value\\\": \\\"\\\"\r\n\t                }\r\n\t            ]\r\n\t        }\r\n\t    ]\r\n\t}\"\r\n\r\ncurl -s -d \"payload=$json\" \"$slackwebhook\"\r\n```"}}
{"actor":{"display_login":"darenwelsh"}}