Rosetta Code/List authors of task descriptions: Difference between revisions

→‎{{header|Perl 6}}: More efficient, only update things that been changed (The creation date never changes)
m (→‎{{header|Perl 6}}: Add internal anchors for easy vanity searches)
(→‎{{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 'RetreivingRetrieving task information...';
 
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>;
%tasks{@add.[0]<push: $title>}<category> => %catfilter{$categorytitle}; # New Tasks
)}
}
 
if @add {
.say for 'Adding new tasks:', |@add;
}
 
for @add -> $task {
mediawiki-query(
$url, 'pages',
:titles($task.<title>key),
:prop<revisions>,
:rvprop<user|timestamp>,
:rvstart<2000-01-01T01:01:01Z>,
:rvdir<newer>,
:rvlimit<1>
).map(: {
print clear, 1 + $++, ' ', %cat{$category}, ' ', .[0]<title>;
%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) orelseor .die "$!\n";
 
# Add table boilerplate and header
10,333

edits