Anonymous user
User:ImplSearchBot/Code: Difference between revisions
m
ImplSearchBot:0
m (ImplSearchBot:0) |
m (ImplSearchBot:0) |
||
Line 117:
}
# To add here: Post stats on activities:
# 2. Time last run started
my $runtime = time() - $starttime;
my $statsdata = "Pages edited last run: $pagesedited<br/>Time to post all per-language updates: $runtime seconds<br/>Category pulls: $categorypulls<br/>Cache hits: $cachehits<br/>";
&out("Updating stats page. Runtime ($runtime), Pages edited ($pagesedited)\n", 2);
&postpage("User:ImplSearchBot/Stats", $statsdata, "Updating stats data", 0);
&out("Updating bot code page\n", 4);
open my $sourcefile, '<', $0
or die "Finished without updating bot source page";
my $botsource;
$botsource .= $_ while <$sourcefile>;
close $sourcefile;
my $tag = "lang";
&postpage("User:ImplSearchBot/Code", "<$tag perl>$botsource</$tag>", 0);
&out("Updating cache\n", 4);
&commitcache();
&out("Done\n", 3);
exit(0);
sub build_posting
{
my $name = shift;
my $body = shift;
return {$name => $body};
}
sub prep_unimp_posting
{
my $impldiff = shift;
my $language = shift;
my $unimplisting = "";
foreach my $taskname (@$alltasks)
{
Line 146 ⟶ 173:
# Add the task to the unimplemented list, if it's unimplemented, and if it's not in the omit list.
$unimplisting .= "* [[$baretaskname]]\n"
unless(exists $
}
return &build_posting("Template:" . &get_unimpl_template_name($language), $unimplisting);
}
sub prep_omit_posting
{
my $implediff = shift;
my $language = shift;
my $omitlisting = "";
my $omittemplatename = &get_omit_template_name($language);
foreach my $taskname (@$alltasks)
{
# We want the task name, not the fully-qualified wiki name.
my $baretaskname = $taskname;
$baretaskname =~ s/^Category://;
# Add the task to the omission list, if it's omitted.
$omitlisting .= "* [[$baretaskname]]\n"
if(exists $
}
# Note that there's no data in the template.
$implediff->{$language}->{'omit'} = 0
if( "" eq $omitlisting );
return &build_posting("Template:$omittemplatename", $omitlisting);
}
sub prep_listing_posting
{
my $impldiff = shift;
my $language = shift;
my $targetcount = $impldiff->{$language}->{'target_count'};
my $unimpcount = $impldiff->{$language}->{'unimp_count'};
# Prepare template fields
Line 163 ⟶ 223:
my $imppercfield = sprintf "|%u", $impperccalc;
# Prepare the listing page format.
my $pagedata = '{{unimpl_header' . $langfield . $unimpfield . $tcfield . $imppercfield . '}}';
$pagedata .= "{{
if (
{
$pagedata .= "{{omit_header" . "$langfield}}";
$pagedata .= "{{" . &get_omit_template_name($
}
$pagedata .= "{{unimpl_footer$langfield}}";
return &build_posting(&get_listing_name($language), $pagedata);
}
sub prep_omit_cat_posting
{
my $implediff = shift;
my $language = shift;
return &build_posting(&get_omit_cat_name, "{{omit_cat|$language}}");
}
sub get_listing_name
{
my $language = shift;
return "Tasks not implemented in $language";
}
sub get_omit_template_name
{
my $language = shift;
return "unimp_omit_body_$language";
}
sub get_unimpl_template_name
{
my $language = shift;
return "unimp_body_$language";
}
sub get_omit_cat_name
{
my $language = shift;
return "Category:$language/Omit";
}
sub process_language
{
my $implediff = shift;
my $language = shift;
my $unimpl = &prep_unimp_posting($implediff, $language);
my $omit = &prep_omit_posting($implediff, $language);
my $listing = &prep_listing_posting($implediff, $language);
my %langpostings = ( %$unimpl, %$omit, %$listing );
unless ( exists $createdomitcategories{&get_omit_cat_name($language)} )
{
my $omit_cat = &prep_omit_cat_posting($implediff, $language);
%langpostings = ( %langpostings, %$omit_cat );
}
return \%langpostings;
}
sub processimplediff
{
my $implediff = shift;
my %work;
foreach my $language (keys %impldiff)
{
&out("Preparing data for:$language\n", 4);
my $workitem = &process_language($implediff, $language);
%work = ( %work, %$workitem );
}
foreach my $pagename (keys %work)
{
&
}
}
sub geteditor
Line 489 ⟶ 570:
return undef
if( ( 0 == scalar keys %omit) && (0 == scalar keys %impl));
# Language metadata
my $unimpcount = scalar @$alltasks - scalar keys %impl;
my $targetcount = (scalar @$alltasks - scalar keys %omit);
# work to do.
return {'impl' => \%impl,
'omit' => \%omit
'unimp_count' => $unimpcount,
'target_count' => $targetcount };
}
|