Rosetta Code/List authors of task descriptions: Difference between revisions
Rosetta Code/List authors of task descriptions (view source)
Revision as of 22:11, 9 June 2019
, 5 years ago→{{header|Perl 6}}: More efficient, only update things that been changed (The creation date never changes)
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Add internal anchors for easy vanity searches) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: More efficient, only update things that been changed (The creation date never changes)) |
||
Line 49:
# clear screen
run($*DISTRO.is-win ?? 'cls' !! 'clear');
%tasks = $hashfile.IO.e ?? $hashfile.IO.slurp.&from-json !! ( );
sleep 1;
#=begin update
note '
my %filter;
for %cat.keys.sort -> $category {
mediawiki-query(
$url, 'pages',
Line 62 ⟶ 66:
:rawcontinue(),
:prop<title>
).map( { %filter{.<title>} = %cat{$category} } )
}
mediawiki-query(▼
$url, 'pages',▼
my $delete = %tasks.keys (-) %filter.keys;
:titles(.<title>),▼
:prop<revisions>,▼
%tasks.delete($_) for $delete.keys; #Tasks that have changed names or been removed
:rvprop<user|timestamp>,▼
:rvstart<2000-01-01T01:01:01Z>,▼
my @add;
:rvdir<newer>,▼
for %filter.keys -> $title {
:rvlimit<1>▼
if %tasks{$title}:exists {
)}▼
%tasks{$title}<category> = %filter{$title} # update status
).map({▼
} else {
print clear, 1 + $++, ' ', %cat{$category}, ' ', .[0]<title>;▼
}
if @add {
.say for 'Adding new tasks:', |@add;
}
for @add -> $task {
%tasks{.[0]<title>}<category> = $task.value;
%tasks{.[0]<title>}<author> = .[0]<revisions>[0]<user>;
%tasks{.[0]<title>}<date> = .[0]<revisions>[0]<timestamp>.subst(/'T'.+$/, '')
}
Line 99 ⟶ 121:
# Open a file handle to dump table in
my $out = open($tablefile, :w)
# Add table boilerplate and header
|