Add purges after set/edit commands
[gruntmaster-data.git] / lib / Gruntmaster / App / Command / Set.pm
index 3ae62b0d507f7b81c6fb01c23365ec8dca00e199..2624ce4d1d40407a1f6c21d5639ed9054c5abea5 100644 (file)
@@ -3,15 +3,22 @@ package Gruntmaster::App::Command::Set;
 use 5.014000;
 use warnings;
 
-our $VERSION = '5999.000_004';
+our $VERSION = '5999.000_015';
 
 use Gruntmaster::App '-command';
 use Gruntmaster::Data;
 
 use File::Slurp qw/read_file/;
 
+use constant PAGES => {
+       contests => '/ct/',
+       jobs     => '/log/',
+       problems => '/pb/',
+       users    => '/us/',
+};
+
 sub opt_spec {
-       ['file!', 'Use the contents of a file as value'],
+       ['file!', 'Use the contents of a file as value']
 }
 
 sub usage_desc { "%c [-cjpu] set id column value [column value ...]\n%c [-cjpu] set --file id column filename [column filename ...]" }
@@ -29,6 +36,7 @@ sub execute {
        my ($id, %values) = @$args;
        %values = map { $_ => scalar read_file $values{$_} } keys %values if $opt->{file};
        db->update($self->app->table, \%values, {id => $id});
+       purge PAGES->{$self->app->table}.$_ for '', $id;
 }
 
 1;
@@ -63,7 +71,7 @@ Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2015 by Marius Gavrilescu
+Copyright (C) 2014-2015 by Marius Gavrilescu
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself, either Perl version 5.20.1 or,
This page took 0.010817 seconds and 4 git commands to generate.