index: release v1.18 with only altgr index linked
[sheet.git] / tools / mkusage-wikimedia
index bf893ce03e08fad9949dd6c6ee879388739466ad..71d6e5fa077000cf2fb40541d3ab8ab4fb6cf0e8 100755 (executable)
@@ -4,13 +4,13 @@ use warnings;
 
 use Data::Dump 'pp';
 
-our $VERSION = '1.01';
+our $VERSION = '1.03';
 
 my %BROWSERID = qw(
-       IE                      ie
+       IE                      edge
        IE-Mobile               ie_mob
-       Edge                    ie
-       Edge-Mobile             ie
+       Edge                    edge
+       Edge-Mobile             edge
        Firefox                 firefox
        Firefox-Mobile          and_ff
        Safari                  safari
@@ -18,13 +18,15 @@ my %BROWSERID = qw(
        Mobile-Safari-UIWebView ios_saf
        Chrome                  chrome
        Chromium                chrome
-       Chrome-Mobile           android
-       Chrome-Mobile-iOS       android
-       Android                 android
+       Chrome-Mobile           and_chr
+       Chrome-Mobile-iOS       and_chr
+       Android                 and_chr
        Opera                   opera
        Opera-Mini              op_mini
        BlackBerry-WebKit       bb
        UC-Browser              and_uc
+       Samsung-Internet        samsung
+       Google                  0
        Other                   0
 );
 
@@ -33,14 +35,21 @@ my %count = (
        -site   => 'https://analytics.wikimedia.org/',
 );
 
-my $recent = qr/^2018-/;
-
 (readline =~ y/\t//) == 3 or die "unexpected amount of columns in header\n";
+my @lines = readline;
+
+my $recent;  # minimum date to include
+for (reverse @lines) {
+       my ($date) = /(\S+)/;
+       $recent ne $date or next if $recent;  # same day
+       $recent = $date;  # override older date
+       last if state $i++ >= 2;  # repeat twice
+}
 
-while (my $row = readline) {
+for my $row (@lines) {
        $row =~ s/\r?\n\z//;
        my ($date, $name, $version, $pct) = split /\t/, $row;
-       $date =~ $recent or next;
+       $date ge $recent or next;
        $name =~ y/ /-/;
        my $browser = $BROWSERID{$name};
        if (not $browser) {