Skip to content

Instantly share code, notes, and snippets.

@yoe
Last active January 17, 2021 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoe/d36691d9b6ce5acbfad6498a8c62546e to your computer and use it in GitHub Desktop.
Save yoe/d36691d9b6ce5acbfad6498a8c62546e to your computer and use it in GitHub Desktop.
SReview statistics generator
#!/usr/bin/perl -w
use strict;
use warnings;
use feature "say";
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new(timeout => 10);
$ua->proxy->detect;
my $overview = $ua->get("https://upload.video.fosdem.org/api/v1/event/2/overview")->result->json;
my %rooms;
my %states;
foreach my $talk(@$overview) {
if(!exists($rooms{$talk->{room}})) {
$rooms{$talk->{room}} = {};
}
if(!exists($rooms{$talk->{room}}{$talk->{state}})) {
$rooms{$talk->{room}}{$talk->{state}} = 1;
} else {
$rooms{$talk->{room}}{$talk->{state}}++;
}
if(!exists($states{$talk->{state}})) {
$states{$talk->{state}} = 1;
} else {
$states{$talk->{state}}++;
}
}
say "Per-room totals:";
foreach my $room(sort keys %rooms) {
say "\t$room";
foreach my $state(sort keys %{$rooms{$room}}) {
say "\t\t$state: $rooms{$room}{$state}";
}
}
say "\nGlobal totals:";
foreach my $state(sort keys %states) {
say "\t$state: $states{$state}";
}
say "\nGlobal total of " . scalar(@$overview) . " talks";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment