Skip to content

Commit

Permalink
Only check embargo status before initial checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 21, 2024
1 parent fc9ab1c commit 63c61ab
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
3 changes: 0 additions & 3 deletions lib/Cavil/Controller/Queue.pm
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ sub create_package ($self) {
$prio + 10
);
}
else {
$pkgs->obs_embargo($obj->{id}, {api => $api, external_link => $obj->{external_link}});
}

$self->render(json => {saved => $obj});
}
Expand Down
10 changes: 0 additions & 10 deletions lib/Cavil/Model/Packages.pm
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,6 @@ sub name_suggestions ($self, $partial) {
)->arrays->flatten->to_array;
}

sub obs_embargo ($self, $id, $data, $priority = 5) {
my $pkg = $self->find($id);
return $self->minion->enqueue(
obs_embargo => [$id, $data] => {
priority => $priority,
notes => {external_link => $pkg->{external_link}, package => $pkg->{name}, "pkg_$id" => 1}
}
);
}

sub obs_import ($self, $id, $data, $priority = 5) {
my $pkg = $self->find($id);
return $self->minion->enqueue(
Expand Down
3 changes: 1 addition & 2 deletions lib/Cavil/Task/Import.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ use Mojo::File qw(path);
use Cavil::Util qw(request_id_from_external_link);

sub register ($self, $app, $config) {
$app->minion->add_task(obs_embargo => \&_embargo);
$app->minion->add_task(obs_import => \&_obs);
$app->minion->add_task(obs_import => \&_obs);
}

sub _embargo ($job, $id, $data) {
Expand Down
8 changes: 3 additions & 5 deletions t/embargo.t
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ subtest 'Embargoed packages' => sub {
start => sub {
my $job = shift;
my $task = $job->task;
return unless $task eq 'obs_import' || $task eq 'obs_embargo';
return unless $task eq 'obs_import';
$job->app->obs(Cavil::OBS->new(config => $job->app->obs->config));
my $api = 'http://127.0.0.1:' . $job->app->obs->ua->server->app($mock_app)->url->port;
$job->args->[1]{api} = $api;
Expand Down Expand Up @@ -179,8 +179,7 @@ subtest 'Embargoed packages' => sub {

subtest 'Check embargo status on re-import' => sub {
$t->app->packages->obsolete_if_not_in_product(3);
is $t->app->minion->jobs({tasks => ['obs_import']})->total, 1, 'one import job';
is $t->app->minion->jobs({tasks => ['obs_embargo']})->total, 0, 'no embargo jobs';
is $t->app->minion->jobs({tasks => ['obs_import']})->total, 1, 'one import job';

$t->post_ok('/packages' => {Authorization => 'Token test_token'} => form => $form)->status_is(200)
->json_is('/saved/checkout_dir', '236d7b56886a0d2799c0d114eddbb7ff')->json_is('/saved/id', 3);
Expand All @@ -189,8 +188,7 @@ subtest 'Embargoed packages' => sub {
->status_is(200)->json_is('/imported/id', 3)->json_is('/imported/state', 'new');
$t->get_ok('/package/3' => {Authorization => 'Token test_token'})->status_is(200)->json_is('/state', 'new')
->json_is('/priority', 5)->json_is('/embargoed', 1)->json_is('/external_link', 'ibs#4321');
is $t->app->minion->jobs({tasks => ['obs_import']})->total, 1, 'one import job';
is $t->app->minion->jobs({tasks => ['obs_embargo']})->total, 1, 'one embargo job';
is $t->app->minion->jobs({tasks => ['obs_import']})->total, 1, 'one import job';
};
};

Expand Down

0 comments on commit 63c61ab

Please sign in to comment.