User:AnomieBOT/source/tasks/ArticleCreationGrapher.pm: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: ArticleCreationGrapher: * Fix image filename.
AnomieBOT (talk | contribs)
Updating published sources: ArticleCreationGrapher: * Add separate thumbnail size setting. * Fix "nextrun" logic. * Add the ability to label events at the top of the graph.
Line 41:
graph => 'File:File-WikiProject Medicine - Dermatology task force - Articles created.svg',
size => [1000,600],
thumbsize => 800,
graph_cats => [],
x2ticsettings => 'rotate by 0 scale 0.4',
x2tics => '',
},
);
Line 77 ⟶ 80:
pages => {},
};
#XXX next if $pgdata->{'nextrun'} > time();
my @pp=();
if($nonet){
Line 85 ⟶ 87:
}
} else {
#XXX next if $pgdata->{'nextrun'} > time();
my $i=$api->iterator(
generator => 'categorymembers',
Line 181 ⟶ 184:
my $pid = open2(*R, *W, @gnuplot);
my ($w,$h)=@{$page->{'size'}};
my $range='["'.g_tt($pp[0]{'ts'}).'":"'.g_tt(time).'"]';
print W <<EOH ;
set terminal svg enhanced size $w $h font "DejaVu Sans"
Line 190 ⟶ 194:
 
set xdata time
set x2data time
set timefmt "%Y-%m"
set xtics nomirror out format "%b %Y"
 
set xrange $range
set x2range $range
EOH
print W <<EOH if $page->{x2tics} ne '';
set x2tics nomirror out $page->{x2ticsettings}
set x2tics ($page->{x2tics})
set grid x2tics
EOH
 
my @t=localtime $pp[0]{'ts'};
my $end=strftime('%Y-%m', localtime);
Line 244 ⟶ 258:
next;
}
my $txt="This is a compilation of article creation dates for $page->{for}\n\nThis page is generated by {{User|".$api->user."}} once a month. Last generated: ~~~~~\n\n[[$page->{graph}|".$page->{'sizethumbsize'}[0]."px|frameless|center|alt=Line graph of article and redirect creation dates by month]]\n\n{| class=\"wikitable\"\n! Article Created !! Article Title !! Type\n";
foreach my $p (@pp){
$txt.="|-\n| ".strftime('%F, %T', gmtime $p->{'ts'})." || [[:".$p->{'title'}."]] || ".($p->{'redir'}?'Redirect':'Article')."\n";
Line 309 ⟶ 323:
sub g_tt {
my @t=localtime shift;
return strftime('%Y-%m-%d', 0,0,0,1,$t[4],$t[5]);
}
 
Line 330 ⟶ 344:
if($dt ne $xx && $a!=$aa){
my @t=split(/-/,$dt);
my $dt2=strftime('%Y-%m-%d', 0,0,0,1,$t[1]-2,$t[0]-1900);
print $fh "$dt2 $aa\n" if(defined($pv) && $pv ne $dt2);
print $fh "$dt $a\n";