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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: DatedCategoryCreator: * Update for rename of Category:Category needed to Category:Uncategorized pages.
AnomieBOT (talk | contribs)
Updating published sources: DatedCategoryCreator: * Use correct key from allcategories response.
 
(7 intermediate revisions by the same user not shown)
Line 37:
'Uncategorized pages' => 'Uncategorized from ',
'Articles needing expert attention by month' => 'Articles needing expert attention from ',
'Wikipedia articles with style issues by month' => 'Wikipedia articles with style issues from ',
);
my %rcatmap=reverse %catmap;
Line 55 ⟶ 56:
'Articles containing potentially dated statements' => 31622400,
'Articles that include images for deletion' => 8*86400,
'Clean-up categories' => 31622400,
);
 
Line 86 ⟶ 88:
 
sub approved {
return 32;
}
 
Line 154 ⟶ 156:
return $res if $res;
}
}
 
# Part 3: Look for missing dated categories beginning with "Clean-up categories from".
$iter = $api->iterator(
list => 'allcategories',
acprefix => 'Clean-up categories from ',
acprop => 'size|hidden',
aclimit => 'max',
formatversion => 2,
);
while ( my $c = $iter->next ) {
if ( ! $c->{'_ok_'} ) {
$api->warn( "Could not retrieve category list from iterator: " . $c->{'error'} . "\n" );
return 60;
}
next unless $c->{'category'} =~ / $monthre \d{4}$/;
next if $c->{'hidden'} || $c->{'size'} <= 0;
next if exists( $did{'Category:' . $c->{'category'}} );
$did{'Category:' . $c->{'category'}}=1;
$res = $self->make_dated_cat( $api, 'Category:' . $c->{'category'}, 'non-empty month' );
return $res if $res;
}
 
Line 175 ⟶ 198:
 
# Figure out the parent cat, and calculate the parameters for {{Monthly
# clean -up category}}.
my $parent=$title;
my $txttmplparams='{{Monthly clean up category';
$parent=~s/^Category://;
$parent=~s/($monthre) (\d{4})$//;
Line 183 ⟶ 206:
if(exists($rcatmap{$parent})){
$parent=$rcatmap{$parent};
$txttmplparams.="|cat=$parent";
} else {
return 0 unless $parent=~s/ from $//;
Line 192 ⟶ 215:
return 0 if $y>$t[5]+1900;
return 0 if($y==$t[5]+1900 && $monthnum{$m}>$t[4]+1);
return 0 if(!exists($oldcats{$parent}) && $y<20042010);
$txt.='}}';
 
# Check whether the parent cat actually exists and is a subcat of the meta
Line 199 ⟶ 221:
my $res=$api->query(
titles => "Category:$parent",
prop => 'categories|templates',
clcategories => 'Category:Wikipedia maintenance categories sorted by month|Category:Wikipedia categories sorted by month',
tltemplates => 'Template:Parent monthly maintenance category',
);
if($res->{'code'} ne 'success'){
Line 211 ⟶ 234:
return 0;
}
my ($type, $txt);
if(grep $_->{'title'} eq 'Category:Wikipedia maintenance categories sorted by month', @{$res->{'categories'}}){
if ( grep $type=_->{'title'} eq 'Template:Parent monthly maintenance category';, @{$res->{'templates'}} ) {
$type='maintenance category';
$txt="{{Monthly maintenance category$tmplparams}}";
} else {
$type='clean-up category';
$txt="{{Monthly clean-up category$tmplparams}}";
}
} elsif(grep $_->{'title'} eq 'Category:Wikipedia categories sorted by month', @{$res->{'categories'}}){
$type='category';
$txt="{{Monthly maintenance category$tmplparams}}";
} else {
$api->warn("Did not create category $title, because parent category $parent is not in Category:Wikipedia maintenance categories sorted by month or Category:Wikipedia categories sorted by month");