Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (23 sloc) 1.1 KB
#!/usr/bin/env perl6
use JSON::Tiny;
my @months_numeral = "0" «~« (19);
@months_numeral.append(<10 11 12>);
my @months = <2015 2016 2017> X~ @months_numeral;
@months.pop;
my $fh = open "new_repos.csv", :w;
my $fh2 = open "rank.csv", :w;
$fh.say("Perl, Perl6");
$fh2.say("Perl, Perl6");
for @months -> $m {
# Taken from https://stackoverflow.com/questions/41475499/how-to-measure-language-popularity-via-github-archive-data
say "Querying $m";
my $output = qqx{bq query --format json "SELECT COUNT(*) c, JSON_EXTRACT_SCALAR(payload, '\$.pull_request.base.repo.language') lang FROM [githubarchive:month.$m] WHERE JSON_EXTRACT_SCALAR(payload, '\$.pull_request.base.repo.language') IS NOT NULL GROUP BY 2 ORDER BY 1 DESC LIMIT 100"};
my @ranking = from-json( $output );
my @perls = @ranking[0].pairs.grep( { $^þ.values[0]{'lang'} ~~ /Perl/ } );
my $year = $m.substr(0,4);
my $month = $m.substr(4);
$fh.say( "$year/$month, ", (@perls.map: *.values.map( { $^þ{'c'} } )).flat.join( ", " ) );
$fh2.say( "$year/$month, ", (@perls.map: *.keys ).flat.join(", ") );
}
$fh.close;
$fh2.close;