r97462 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97461‎ | r97462 | r97463 >
Date:10:43, 19 September 2011
Author:ezachte
Status:deferred
Tags:
Comment:
new section in wikistats progress reports to show per project per target language age of reports
Modified paths:
  • /trunk/wikistats/progress/WikiCountsJobProgress.pl (modified) (history)

Diff [purge]

Index: trunk/wikistats/progress/WikiCountsJobProgress.pl
@@ -124,7 +124,7 @@
125125 &ReadStatsCsv ("wv") ;
126126 &ReadStatsCsv ("wx") ;
127127
128 - &ReadStatsHtml ($dir_html,"") ;
 128+ &ReadStatsHtml ($dir_html,"wikipedia") ;
129129 &ReadStatsHtml ($dir_html,"wikibooks") ;
130130 &ReadStatsHtml ($dir_html,"wiktionary") ;
131131 &ReadStatsHtml ($dir_html,"wikinews") ;
@@ -314,7 +314,11 @@
315315 my $dir = shift ;
316316 my $project = shift ;
317317
318 - $dir = "$dir/$project" ;
 318+ if ($project ne "wikipedia")
 319+ { $dir = "$dir/$project" ; }
 320+
 321+ my @languages ;
 322+
319323 my $lastdir = getcwd();
320324 chdir ($dir) || die "Cannot chdir to $dir\n";
321325 local (*DIR);
@@ -330,24 +334,46 @@
331335 }
332336 closedir DIR;
333337
 338+ $project2 = ucfirst ($project) ;
 339+
 340+ $reports {$project} = "<p><b>$project2</b> <small>[count]</small> " ;
 341+ $reports_cnt = 0 ;
334342 foreach $language (sort @languages)
335343 {
336 - $file_age = int (-M "$dir/$language/index.html") ;
337 - $file_date = time - int (24*60*60*(-M "$dir/$language/index.html")) ;
338 - if ($language eq "EN")
339 - {
 344+ $language_lc = lc ($language) ;
 345+
 346+ $file_age = -M "$dir/$language/index.html" ;
 347+ $file_age_days = int ($file_age) ;
 348+ $file_age_min = int (24*60 *$file_age) ;
 349+ $file_age_secs = int (24*60*60*$file_age) ;
 350+ $file_date = time - $file_age_secs ;
 351+ # if ($language eq "EN")
 352+ # {
340353 if ($project eq "")
341354 { $project = "wikipedia" ; }
342 - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=gmtime($file_date);
343 - my $now_gm = sprintf ("%02d-%02d-%04d %02d:%02d\n",$mday,$mon+1,$year+1900,$hour,$min) ;
344 - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($file_date);
345 - my $now = sprintf ("%02d-%02d-%04d %02d:%02d\n",$mday,$mon+1,$year+1900,$hour,$min) ;
346 - $project2 = ucfirst ($project) ;
347 - $reports {$project} = "<tr><td><small>$project2</small></td><td><small>$now EST</small></td><td><small>=</small></td><td><small>$now_gm GMT</small></td></tr>" ;
348 - $report_dates {$project} = $file_date ;
349 - $reports_total ++ ;
350 - }
 355+
 356+ ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime ($file_date);
 357+
 358+ $file_ago = $file_age_days ;
 359+ if ($file_ago == 0)
 360+ { $file_ago = " <u>0 days, $file_age_min min</u>" ; }
 361+
 362+ $color = "green" ;
 363+ if ($file_ago > 30)
 364+ { $color = "darkred" ; }
 365+ $reports {$project} .= "<small><font color=$color>$language_lc<sup>$file_ago</sup></font></small>, " ;
 366+ $reports_cnt ++ ;
 367+
 368+ if ($language eq "EN")
 369+ {
 370+ $report_dates {$project} = $file_date ;
 371+ $reports_total ++ ;
 372+ }
 373+ # }
351374 }
 375+ $reports {$project} =~ s/, $// ;
 376+ $reports {$project} =~ s/count/$reports_cnt/ ;
 377+
352378 chdir ($lastdir) ;
353379 }
354380
@@ -504,13 +530,16 @@
505531 {
506532 print HTML "<a name='reports' id='reports'></a>" .
507533 "<hr><b>Reports generated</b>\n" .
508 - "<table>\n";
 534+ "<small>This section shows -per project per target language- the file age of index.html in days (for age < 24 hours in minutes). " .
 535+ "Note that a very recently generated report does not always contain counts up to the previous month. " .
 536+ "See above for how up to data counts are per project language. " .
 537+ "Color green here means: reports have been generated and published less than 30 days ago.</small>" ;
 538+
 539+
509540 foreach $report (sort {$report_dates {$b} <=> $report_dates {$a}} keys %report_dates)
510541 { print HTML $reports {$report} . "\n" ; }
511 - print HTML "</table>\n</small>\n" ;
512542 }
513543
514 -
515544 print HTML "<hr><p><b>Longest jobs</b> <small>\n" ;
516545 $html = "<table border=1 spacing=0><tr><td valign=top><table>\n" ;
517546 $jobs = 0 ;
@@ -628,6 +657,9 @@
629658 "</style>\n" .
630659
631660 "<body bgcolor=#CCCCCC>\n" ;
 661+ print HTML "<h3>Disclaimer</h3>\n" ;
 662+ print HTML "<small>This report offers a very concise overview of wikistats status for data collecting and reporting." .
 663+ "This is not an official WMF publication. It has been built by Erik Zachte primarily for personal use.</small>\n" ;
632664 print HTML "<h3>Cached files from <a href='http://dammit.lt/wikistats'>http://dammit.lt/wikistats</a></h3>\n" ;
633665 print HTML "<p><small><pre>\n" ;
634666 print HTML "../projectcounts: " . sprintf ("%4d", $files_projectcounts) . " files, newest file $file_new_projectcounts\n" ;
@@ -645,7 +677,11 @@
646678
647679 print HTML "</pre></small>" ;
648680
649 - print HTML "<hr><p><h3>Progress per project</h3>" ;
 681+ print HTML "<hr><p><h3>Progress per project, collecting data</h3>" .
 682+ "<small>This section shows -per project per wiki language- how many days ago data were collected and till when. " .
 683+ "Days ago is shown in superscript. For jobs which ran an hour or more this is followed by run time, and language code is shown in bold. " .
 684+ "The color signals up till which month data have been processed. Best is up till last month which is shown in green. See also <a href='#legend'>legend</a>.</small> " ;
 685+
650686 $html = "" ;
651687 $project_prev = "" ;
652688 foreach $run (sort keys %runtimes2)
@@ -719,6 +755,19 @@
720756 { $project2 = "<u>$project2</u>" ; }
721757 print HTML "<p><b>$project2</b> <small>[$languages] $html</small>\n" ;
722758
 759+ if ($reports_total > 0)
 760+ {
 761+ print HTML "<a name='reports' id='reports'></a>\n" .
 762+ "<hr><p><h3>Progress per project, reporting</h3>" .
 763+ "<small>This section shows -per project per target language- the file age of index.html in days (for age < 24 hours in minutes). " .
 764+ "Note that a very recently generated report does not always contain counts up to the previous month. " .
 765+ "See above for how up to data counts are per project language. " .
 766+ "Color green here means: reports have been generated and published less than 30 days ago.</small>" ;
 767+
 768+ foreach $report (sort {$report_dates {$b} <=> $report_dates {$a}} keys %report_dates)
 769+ { print HTML $reports {$report} . "\n" ; }
 770+ }
 771+
723772 print HTML "<hr>" ;
724773 &WriteHtmlJobRunTimes ;
725774

Status & tagging log