Content deleted Content added
Updating published sources: ArticleCreationGrapher: * Deny Svenbot from image page. |
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. |
||
(4 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:
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/);
foreach my $page (@pages){
return 0 if $api->halting;
my $pgdata=$api->store->{$page->{'page'}} // {▼
#
if ( exists( $api->store->{$page->{'page'}}
};▼
$api->store->{'epoch:'.$page->{'page'}} = $pgdata->{'epoch'} // 0;
$api->store->{'nextrun:'.$page->{'page'}} = $pgdata->{'nextrun'};
$api->store->{'pg:'.$page->{'page'}} = $pgdata->{'pages'};
delete( $api->store->{$page->{'page'}} );
my $nextrun = $api->store->{'nextrun:'.$page->{'page'}} // 0;
my $pages = $api->store->{'pg:'.$page->{'page'}} // {};
my @pp=();
if($nonet){
foreach my $v (values %
next unless ref($v) eq 'HASH';
push @pp, { redir=>$v->{'r'}, ts=>$v->{'t'}, title=>$v->{'tt'} };
}
} else {
next if($
$api->log( "Loading data to graph " . $page->{'page'} );
my $i=$api->iterator(
generator => 'categorymembers',
Line 111 ⟶ 121:
foreach my $p (@pageids) {
return 0 if $api->halting;
if(exists($
push @px, $p;
next;
Line 117 ⟶ 127:
if($ct++>=100){
# periodic save
$api->store->{'pg:'.$page->{'page'}}=$
$ct=0;
}
Line 128 ⟶ 138:
);
if($res->{'code'} eq 'shutoff'){
$api->store->{'pg:'.$page->{'page'}}=$
$api->warn("Task disabled: ".$res->{'content'}."\n");
return 300;
}
if($res->{'code'} ne 'success'){
$api->store->{'pg:'.$page->{'page'}}=$
$api->warn("Failed to get info for $p: ".$res->{'error'}."\n");
return 60;
Line 143 ⟶ 153:
next if $ts eq '';
$ts=$api->ISO2timestamp($ts);
$
t=>$ts,
r=>$is_redir,
Line 153 ⟶ 163:
ts=>$ts,
};
}
$api->store->{'pg:'.$page->{'page'}}=$
if(@px){
my %q=(
Line 171 ⟶ 180:
}
my $p=$_->{'pageid'};
$
$
push @pp, {
title=>$_->{'title'},
redir=>$
ts=>$
};
}
$api->store->{'pg:'.$page->{'page'}}=$
}
}
$api->log( "Graphing data for " . $page->{'page'} );
@pp=sort {
my $x=($a->{'ts'} <=> $b->{'ts'});
Line 219 ⟶ 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 254 ⟶ 265:
if($page->{'writepage'}){
$api->log( "Updating " . $page->{'page'} );
my $tok=$api->edittoken($page->{'page'});
if($tok->{'code'} eq 'shutoff'){
Line 282 ⟶ 294:
}
$api->log( "Uploading image file " . $page->{'graph'} . ' for ' . $page->{'page'} );
my $tok=$api->edittoken($page->{'graph'});
if($tok->{'code'} eq 'shutoff'){
Line 292 ⟶ 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{{
foreach my $c (@{$page->{'graph_cats'}}){
$txt.="[[Category:$c]]\n";
Line 307 ⟶ 320:
}
@t=gmtime;
$
$
$api->store->{'nextrun:'.$page->{'page'}}=timegm(0,0,0,1,$t[4]+1,$
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 321 ⟶ 335:
}
}
}
Line 327 ⟶ 340:
my $t=undef;
foreach my $page (@pages){
my $
$t=$
}
return $t-time();
|