Skip to content

Instantly share code, notes, and snippets.

@MagnusEnger
Created August 4, 2011 11:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MagnusEnger/1125015 to your computer and use it in GitHub Desktop.
Save MagnusEnger/1125015 to your computer and use it in GitHub Desktop.
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