Erik Zachte has submitted this change and it was merged.
Change subject: show for last 7 days how many dumps were processed each day
......................................................................
show for last 7 days how many dumps were processed each day
Change-Id: I4d06fe883a7cc2a3984c64996aef15adf06ce143
---
M dumps/perl/WikiCountsJobProgress.pl
A dumps/perl/WikiCountsJobProgressNotify.pl
2 files changed, 78 insertions(+), 1 deletion(-)
Approvals:
Erik Zachte: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/dumps/perl/WikiCountsJobProgress.pl
b/dumps/perl/WikiCountsJobProgress.pl
index c284aba..cd5d6a9 100644
--- a/dumps/perl/WikiCountsJobProgress.pl
+++ b/dumps/perl/WikiCountsJobProgress.pl
@@ -18,6 +18,7 @@
use Time::Local ;
use Getopt::Std ;
use Cwd ;
+ use Time::Piece ;
my %options ;
getopt ("dipou", \%options) ;
@@ -61,7 +62,9 @@
$file_html = "$dir_out/out_wm/WikiCountsJobProgress.html" ;
$file_html_c = "$dir_out/out_wm/WikiCountsJobProgressCurrent.html" ;
-
+
+ $file_daily_gain = "$dir_out/out_wm/WikiCountsJobProgressDaily.txt" ;
+
&ReadWikiCountsThresholdEditsOnly ;
# &ReadDammitStats ; # process to process dammit files is no longer in use,
new version not yet live
@@ -162,9 +165,11 @@
"<br><font color=#800000>xx<sup>n</sup></font>: last month
processed: $month_minus_4 or older\n" .
"<br><font color=#808080>xx<sup>n</sup></font>: wiki is
closed\n" .
"<br>Bold text: job took an hour or more</small>\n" ;
+
&WriteHtml ;
&WriteHtmlCurrent ;
&WriteHtmlJobRunTimes ;
+ &WriteDailyGain ;
print "Ready in " . (time - $timestart) . " sec\n" ;
exit;
@@ -531,6 +536,11 @@
elsif ($months == 0) # wikistats up to date, contains data up to previous
month
{ $rgb = "#008000" ; }
+ if (($language eq "sep11") || ($months == 0))
+ { $done_per_project {$project} ++ ; }
+ else
+ { $todo_per_project {$project} ++ ; }
+
$runtime = int ($runtimes {$run} / 60) ;
if (! @dblists {"$project,$language"})
@@ -790,6 +800,25 @@
{ $project2 = "<u>$project2</u>" ; }
print HTML "<p><b>$project2</b> <small>[$languages] $html</small>\n" ;
+ if (-e $file_daily_gain)
+ {
+ open TXT, '<', $file_daily_gain ;
+ @lines_daily_gain = <TXT> ;
+ close TXT ;
+ }
+
+ # feed last 7 status lines to html
+ print HTML "<h3>Progress in last week</h3>\n" ;
+ print HTML "<pre>at end of day still to do:\n" ;
+ $l = $#daily_lines_gain ;
+ for ($l = $#lines_daily_gain >= 6 ? $#lines_daily_gain - 6 : 0 ; $l <=
$#lines_daily_gain ; $l++)
+ {
+ last if $l < 0 ;
+ print HTML $lines_daily_gain [$l] ;
+ print "$l " . $lines_daily_gain [$l] ;
+ }
+ print HTML "</pre>\n" ;
+
if ($reports_total > 0)
{
foreach $project (sort {$report_dates {$b} <=> $report_dates {$a}} keys
%report_dates)
@@ -894,6 +923,31 @@
print HTML "</table>\n" ;
}
+sub WriteDailyGain
+{
+ my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst)=localtime(time -
24*3600); # collect stats for end of previous day
+ my $yesterday = sprintf ("%04d-%02d-%02d", $year+1900, $month+1,$mday) ;
+ my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst)=localtime(time);
# compare file date with today
+ my $today = sprintf ("%04d-%02d-%02d", $year+1900, $month+1,$mday) ;
+
+ my $todo = '' ;
+ foreach $project (sort keys %projects)
+ { $todo .= "$project:" . (0 + $todo_per_project {$project}) . '/' .
($done_per_project {$project} + $todo_per_project {$project}) . " " ; }
+
+# print "$today,$done\n" ;
+
+ if (-e $file_daily_gain)
+ {
+ my $ymd = localtime((stat $file_daily_gain)[9])->ymd;
+ return if $ymd eq $today ; # already line added logged today
+ # print "today $today / file date $ymd -> add line\n" ;
+ }
+
+ open TXT, '>>', $file_daily_gain ;
+ print TXT "$yesterday $todo\n" ;
+ close TXT ;
+}
+
sub DHM
{
my $time = shift ;
diff --git a/dumps/perl/WikiCountsJobProgressNotify.pl
b/dumps/perl/WikiCountsJobProgressNotify.pl
new file mode 100644
index 0000000..48fb743
--- /dev/null
+++ b/dumps/perl/WikiCountsJobProgressNotify.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+# no command line parameters (trivial script)
+
+use LWP::UserAgent;
+
+$file = "/a/wikistats_git/dumps/out/out_wm/WikiCountsJobProgressDaily.txt" ;
+
+die "File '$file' not found" if ! -e $file ;
+
+@lines = `tail -n 22$file` ;
+
+$msg = join ("\n", @lines) ;
+
+$result = LWP::UserAgent->new()->post(
+ "https://api.pushover.net/1/messages.json", [
+ "token" => "MvqD8yZuJGbNfZ4KXxnK2cGrndwu4x",
+ "user" => "zzQycwrc5cYdwUc5KUoUWpQpqfWZpk",
+ "message" => "$msg",
+]);
+
+print "Ready" ;
+exit ;
--
To view, visit https://gerrit.wikimedia.org/r/69520
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4d06fe883a7cc2a3984c64996aef15adf06ce143
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wikistats
Gerrit-Branch: master
Gerrit-Owner: Erik Zachte <[email protected]>
Gerrit-Reviewer: Erik Zachte <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits