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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: DatedCategoryCreater: * Ahhh! Accidentally left some testing code in place. Sorry everyone.
AnomieBOT (talk | contribs)
Updating published sources: DatedCategoryCreator: * Allow certain cats to have backdated dates (currently just Category:Wikipedia articles in need of updating). TagDater: * Don't check years in missingcats logic, due to the above change.
Line 43:
my %skipcat=(
'Articles with invalid date parameter in template' => 1
);
 
# Categories to allow old dates
my %oldcats=(
'Wikipedia articles in need of updating' => 1
);
 
Line 55 ⟶ 60:
}
 
my $yearrecuryear;
 
sub new {
Line 87 ⟶ 92:
my %did=();
 
my $curmonth@t=strftime('%B %Y', gmtime(time()+86400));
my $curmonth=strftime('%B %Y', @t);
 
$yearrecuryear=join('|', 2004 .. ((gmtime(time()+86400))$t[5]+1900));
$yearre=qr/$yearre/;
 
# Part 1: Create needed categories for the current month
Line 136 ⟶ 140:
for my $c (@{$p->{'categories'} // []}) {
# Minimal sanity check; make_dated_cat() will do more
next unless $c->{'title'}=~/ $monthre $yearre\d{4}$/;
next if exists($did{$c->{'title'}});
$did{$c->{'title'}}=1;
Line 167 ⟶ 171:
my $txt='{{Monthly clean up category';
$parent=~s/^Category://;
$parent=~s/($monthre) ($yearre\d{4})$//;
my ($m,$y)=($1,$2);
if(exists($rcatmap{$parent})){
Line 176 ⟶ 180:
return 0 if exists($skipcat{$parent});
}
return 0 if $y>$curyear;
return 0 if(!exists($oldcats{$parent}) && $y<2004);
$txt.='}}';