From: Marius Gavrilescu Date: Wed, 3 Feb 2016 14:52:54 +0000 (+0000) Subject: Add purges after set/edit commands X-Git-Tag: 5999.000_016~6 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=8ab124f5b4b8d8c871c3bf2c3fb11eb17f61d2f6;p=gruntmaster-data.git Add purges after set/edit commands --- diff --git a/lib/Gruntmaster/App/Command/Edit.pm b/lib/Gruntmaster/App/Command/Edit.pm index 24785ab..3257903 100644 --- a/lib/Gruntmaster/App/Command/Edit.pm +++ b/lib/Gruntmaster/App/Command/Edit.pm @@ -10,6 +10,9 @@ use File::Slurp qw/read_file write_file/; use Gruntmaster::App '-command'; use Gruntmaster::Data; +use Gruntmaster::App::Command::Set; +BEGIN { *PAGES = *Gruntmaster::App::Command::Set::PAGES } + sub usage_desc { '%c [-cjpu] edit id column' } sub validate_args { @@ -28,6 +31,7 @@ sub execute { my $editor = $ENV{EDITOR} // 'editor'; system $editor, $file; db->update($self->app->table, {$col => scalar read_file $file}, {id => $obj}); + purge PAGES->{$self->app->table}.$_ for '', $obj; } 1; diff --git a/lib/Gruntmaster/App/Command/Set.pm b/lib/Gruntmaster/App/Command/Set.pm index 3ef26fc..2624ce4 100644 --- a/lib/Gruntmaster/App/Command/Set.pm +++ b/lib/Gruntmaster/App/Command/Set.pm @@ -10,6 +10,13 @@ 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'] } @@ -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;