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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: ArticleCreationGrapher: * Adjust storage so it's easier to force a run when needed. * Add {{tl|esoteric file}}. Meh.
AnomieBOT (talk | contribs)
Updating published sources: ArticleCreationGrapher: * Discontinue task. Graph doesn't seem to really be used anymore, and mw:Extension:Graph exists which would be a better way to do it than a monthly file upload.
 
(3 intermediate revisions by the same user not shown)
Line 1:
{{ombox|type=notice|text= Approved 2010-08-29<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 41]]}}
{{ombox|type=notice|text= Task discontinued 2022-01-25. The graph has trailed off, the page it's on hasn't been updated in years and gets minimal views, and we now have [[mw:Extension:Graph]] that can generate graphs from data instead of having to have an image uploaded monthly. If someone still wants such a graph, it would be better to have a bot create a data table somewhere to be graphed via that extension.}}
<syntaxhighlight lang="perl">
package tasks::ArticleCreationGrapher;
Line 10 ⟶ 11:
Task: ArticleCreationGrapher
BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 41
Status: ApprovedInactive 20102022-0801-2925
Created: 2010-08-25
 
Line 60 ⟶ 61:
=for info
Approved 2010-08-29<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 41]]
 
=for info
Task discontinued 2022-01-25. The graph has trailed off, the page it's on hasn't been updated in years and gets minimal views, and we now have [[mw:Extension:Graph]] that can generate graphs from data instead of having to have an image uploaded monthly. If someone still wants such a graph, it would be better to have a bot create a data table somewhere to be graphed via that extension.
 
=cut
 
sub approved {
return -6;
}
 
Line 72 ⟶ 76:
 
$api->task('ArticleCreationGrapher', 0, 10, qw/d::Timestamp/);
 
# Spend a max of 10 minutes on this task before restarting
my $endtime=time()+600;
 
foreach my $page (@pages){
Line 98 ⟶ 99:
} else {
next if($nextrun > time() && ($api->store->{'epoch:'.$page->{'page'}}//0) >= $epoch);
$api->log( "Loading data to graph " . $page->{'page'} );
my $i=$api->iterator(
generator => 'categorymembers',
Line 161 ⟶ 163:
ts=>$ts,
};
return 0 if(time>$endtime);
}
$api->store->{'pg:'.$page->{'page'}}=$pages;
Line 190 ⟶ 191:
}
}
$api->log( "Graphing data for " . $page->{'page'} );
@pp=sort {
my $x=($a->{'ts'} <=> $b->{'ts'});
Line 227 ⟶ 229:
do {
$x=strftime('%Y-%m', 0,0,0,1,$t[4]++,$t[5]);
($t[4], $t[5]) = (1, $t[5]+1) if $t[4] == 13;
print W "," unless $f;
if($x=~/^(\d+)-01$/){
Line 262 ⟶ 265:
 
if($page->{'writepage'}){
$api->log( "Updating " . $page->{'page'} );
my $tok=$api->edittoken($page->{'page'});
if($tok->{'code'} eq 'shutoff'){
Line 290 ⟶ 294:
}
 
$api->log( "Uploading image file " . $page->{'graph'} . ' for ' . $page->{'page'} );
my $tok=$api->edittoken($page->{'graph'});
if($tok->{'code'} eq 'shutoff'){
Line 300 ⟶ 305:
}
my $comment="Updated graph";
my $txt="{{imbox|type=style|image=[[File:Ambox warning yellow.svg|50px]]|imageright=[[File:Crystal Clear action run.svg|50px]]|text=This image is automatically updated by a bot, {{User|".$api->user."}}. Any changes will be overwritten automatically.<center>'''Do not move this file to Wikimedia Commons.'''<br /><small>If for some reason you need to stop the bot, place {{tl|nobots}} on this page or post a message [[User:".$api->user."/shutoff/ArticleCreationGrapher|here]].</small></center>}}\n{{Information\n|description=Bot-generated graph of [[$page->{page}|$page->{for}]] article creation\n|source=Own work, created using [[Gnuplot]]\n|date=~~~~~\n|author={{User|".$api->operator."}} as the author of {{User|".$api->user."}}\n|permission={{PD-self|date=August 2010}}\n}}\n{{bots|deny=Fbot,Svenbot}}\n{{esoteric file}}\n\n[[Category:Wikipedia charts]]\n";
foreach my $c (@{$page->{'graph_cats'}}){
$txt.="[[Category:$c]]\n";
Line 320 ⟶ 325:
 
if(!exists($tok->{'missing'})){
$api->log( "Updating image description for " . $page->{'graph'} );
$res=$api->edit($tok, $txt, "Update page text", 0, 0);
if($res->{'code'} eq 'shutoff'){
Line 329 ⟶ 335:
}
}
return 0 if(time>$endtime);
}