}
sub cmd_add{
- my $id = shift;
+ my ($id) = @_;
my $name = prompt 'Contest name';
my $owner = prompt 'Owner';
my $start = str2time prompt 'Start time' or die 'Cannot parse time';
my $stop = str2time prompt 'Stop time' or die 'Cannot parse time';
- $db->contests->create({id => $id, name => $name, owner => $owner, start => $start, stop => $stop})
+ $db->contests->create({id => $id, name => $name, owner => $owner, start => $start, stop => $stop});
+ purge '/ct/';
}
sub cmd_rm{
- $db->contest(shift)->delete
+ my ($id) = @_;
+ $db->contest(shift)->delete;
+ purge '/ct/';
+ purge "/ct/$id";
}
sub cmd_get{
sub cmd_set{
my ($id, %values) = @_;
- $db->contest($id)->update(\%values)
+ $db->contest($id)->update(\%values);
+ purge '/ct/';
+ purge "/ct/$id";
}
##################################################
}
sub cmd_rm{
- $db->job(shift)->delete
+ my ($id) = @_;
+ $db->job($id)->delete;
+ purge '/log/';
+ purge "/log/$id";
}
sub cmd_get{
sub cmd_set{
my ($id, %values) = @_;
- $db->job($id)->update(\%values)
+ $db->job($id)->update(\%values);
+ purge '/log/';
+ purge "/log/$id";
}
sub cmd_rerun{
- $db->job(shift)->rerun
+ my ($id) = @_;
+ $db->job($id)->rerun;
+ purge '/log/';
+ purge "/log/$id";
}
##################################################
$db->problems->create (\%options);
$db->contest_problems->create({problem => $id, contest => $contest}) if $contest;
+ purge '/pb/';
}
sub cmd_set{
GetOptions ( 'file!' => \$file );
my ($id, %values) = @_;
%values = map { $_ => scalar read_file $values{$_} } keys %values if $file;
- $db->problem($id)->update(\%values)
+ $db->problem($id)->update(\%values);
+ purge '/pb/';
+ purge "/pb/$id";
}
sub cmd_get{
}
sub cmd_rm{
- $db->problem(shift)->delete
+ my ($id) = @_;
+ $db->problem($id)->delete;
+ purge '/pb/';
+ purge "/pb/$id";
}
sub cmd_show{
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-03-05 13:11:39
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dAEmtAexvUaNXLgYz2rNEg
+use parent qw/Exporter/;
our $VERSION = '5999.000_012';
+our @EXPORT = qw/purge/;
use Lingua::EN::Inflect qw/PL_N/;
use JSON::MaybeXS qw/decode_json/;
+use HTTP::Tiny;
use PerlX::Maybe qw/maybe/;
use Sub::Name qw/subname/;
$self->txn_do($txn);
}
+my @PURGE_HOSTS = exists $ENV{PURGE_HOSTS} ? split ' ', $ENV{PURGE_HOSTS} : ();
+my $ht = HTTP::Tiny->new;
+
+sub purge { $ht->request(PURGE => "http://$_$_[0]") for @PURGE_HOSTS }
+
+
1;
__END__