Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Snapshots of the most recent numbers for Koha's bug statuses
#!/usr/bin/perl -w
# Prints out the the most recent numbers for each status from:
# http://bugs.koha-community.org/cgi-bin/progress.pl?type=json
#
# Meant to be run hourly from cron during Global Bug Squashing Days:
# @hourly perl /path/to/kohastatus.pl >> /path/to/hourlynumbers.txt
#
# Based on http://beerpla.net/2008/03/27/parsing-json-in-perl-by-example-southparkstudioscom-south-park-episodes/
use strict;
use WWW::Mechanize;
use JSON -support_by_pp;
my $json_url = 'http://bugs.koha-community.org/cgi-bin/progress.pl?type=json';
# download the json page:
my $browser = WWW::Mechanize->new();
$browser->get( $json_url );
my $content = $browser->content();
my $json = new JSON;
my @jsondata = $json->decode($content);
# Get the right data
my $time = gmtime();
my $needssignoff = $jsondata[0][0][-1][1] ? $jsondata[0][0][-1][1] : 0;
my $signedoff = $jsondata[0][1][-1][1] ? $jsondata[0][1][-1][1] : 0;
my $passedqa = $jsondata[0][2][-1][1] ? $jsondata[0][2][-1][1] : 0;
my $pushed = $jsondata[0][3][-1][1] ? $jsondata[0][3][-1][1] : 0;
# Output
print "$time\t$needssignoff\t$signedoff\t$passedqa\t$pushed\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.