From 8ab124f5b4b8d8c871c3bf2c3fb11eb17f61d2f6 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Wed, 3 Feb 2016 14:52:54 +0000 Subject: [PATCH] Add purges after set/edit commands --- lib/Gruntmaster/App/Command/Edit.pm | 4 ++++ lib/Gruntmaster/App/Command/Set.pm | 8 ++++++++ 2 files changed, 12 insertions(+) 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; -- 2.30.2