diff --git a/lib/Zonemaster/Backend/DB.pm b/lib/Zonemaster/Backend/DB.pm index 9ef0d65e..b83b6469 100644 --- a/lib/Zonemaster/Backend/DB.pm +++ b/lib/Zonemaster/Backend/DB.pm @@ -732,39 +732,6 @@ sub get_test_params { return $result; } -# Standatd SQL, can be here -sub get_batch_job_result { - my ( $self, $batch_id ) = @_; - - die Zonemaster::Backend::Error::ResourceNotFound->new( message => "Unknown batch", data => { batch_id => $batch_id } ) - unless defined $self->batch_exists_in_db( $batch_id ); - - my $dbh = $self->dbh; - - my %result; - $result{nb_running} = 0; - $result{nb_finished} = 0; - - my $query = " - SELECT hash_id, progress - FROM test_results - WHERE batch_id=?"; - - my $sth1 = $dbh->prepare( $query ); - $sth1->execute( $batch_id ); - while ( my $h = $sth1->fetchrow_hashref ) { - if ( $h->{progress} eq '100' ) { - $result{nb_finished}++; - push(@{$result{finished_test_ids}}, $h->{hash_id}); - } - else { - $result{nb_running}++; - } - } - - return \%result; -} - =head2 batch_status Returns number of tests per category (finished, running, waiting) for the given diff --git a/lib/Zonemaster/Backend/RPCAPI.pm b/lib/Zonemaster/Backend/RPCAPI.pm index d38fc35f..e7e8f392 100644 --- a/lib/Zonemaster/Backend/RPCAPI.pm +++ b/lib/Zonemaster/Backend/RPCAPI.pm @@ -737,28 +737,6 @@ sub batch_create { return $result; } -# Deprecated to be removed in v2025.2. -$json_schemas{get_batch_job_result} = joi->object->strict->props( - batch_id => $zm_validator->batch_id->required -); -# Deprecated to be removed in v2025.2. -sub get_batch_job_result { - my ( $self, $params ) = @_; - - my $result; - eval { - my $batch_id = $params->{batch_id}; - - $result = $self->{db}->get_batch_job_result($batch_id); - }; - if ($@) { - handle_exception( $@ ); - } - - return $result; -} - - $json_schemas{batch_status} = { type => 'object', additionalProperties => 0, diff --git a/script/zmb b/script/zmb index a2ffdaa9..2f5d9f63 100755 --- a/script/zmb +++ b/script/zmb @@ -584,34 +584,6 @@ sub cmd_add_batch_job { ); } -=head2 get_batch_job_result (** Deprecated to be removed in Zonemaster version v2025.2. Use C instead. **) - - zmb [GLOBAL OPTIONS] get_batch_job_result [OPTIONS] - - Options: - --batch-id BATCH-ID - -=cut - -sub cmd_get_batch_job_result { - my @opts = @_; - - my $opt_batch_id; - GetOptionsFromArray( - \@opts, - 'batch-id|i=s' => \$opt_batch_id, - ) or pod2usage( 2 ); - - return to_jsonrpc( - id => 1, - method => 'get_batch_job_result', - params => { - batch_id => $opt_batch_id, - }, - ); -} - - =head2 batch_status zmb [GLOBAL OPTIONS] batch_status [OPTIONS] diff --git a/script/zonemaster_backend_rpcapi.psgi b/script/zonemaster_backend_rpcapi.psgi index ebf57a48..78813417 100644 --- a/script/zonemaster_backend_rpcapi.psgi +++ b/script/zonemaster_backend_rpcapi.psgi @@ -169,12 +169,6 @@ my $router = router { action => "domain_history" }; - # Deprecated to be removed v2025.2 - connect "get_batch_job_result" => { - handler => $handler, - action => "get_batch_job_result" - }; - connect "batch_status" => { handler => $handler, action => "batch_status" diff --git a/t/batches.t b/t/batches.t index 603dae46..8c9b526d 100644 --- a/t/batches.t +++ b/t/batches.t @@ -151,8 +151,7 @@ subtest 'RPCAPI add_batch_job' => sub { }; }; -subtest 'RPCAPI get_batch_job_result and batch_status' => sub { - # "get_batch_job_result deprecated to be removed by v2025.2 +subtest 'RPCAPI batch_status' => sub { my $config = Zonemaster::Backend::Config->parse( $config ); my $rpcapi = init_backend( $config ); subtest 'batch job exists' => sub { @@ -168,34 +167,14 @@ subtest 'RPCAPI get_batch_job_result and batch_status' => sub { is( $batch_id, 1, 'correct batch job id returned' ); - { - my $res = $rpcapi->get_batch_job_result( { batch_id => $batch_id } ); - - is( $res->{nb_running}, scalar @domains, 'correct number of runninng tests' ); - is( $res->{nb_finished}, 0, 'correct number of finished tests' ); - } - - { - my $res = $rpcapi->batch_status( { batch_id => $batch_id } ); - - is( $res->{waiting_count}, scalar @domains, 'correct number of runninng tests' ); - is( $res->{running_count}, 0, 'correct number of finished tests' ); - is( $res->{finished_count}, 0, 'correct number of finished tests' ); - ok( !exists $res->{waiting_tests}, 'list of waiting tests expected to be absent' ); - ok( !exists $res->{running_tests}, 'list of running tests expected to be absent' ); - ok( !exists $res->{finished_tests}, 'list of finished tests to be absent' ); - } - }; + my $res = $rpcapi->batch_status( { batch_id => $batch_id } ); + is( $res->{waiting_count}, scalar @domains, 'correct number of runninng tests' ); + is( $res->{running_count}, 0, 'correct number of finished tests' ); + is( $res->{finished_count}, 0, 'correct number of finished tests' ); + ok( !exists $res->{waiting_tests}, 'list of waiting tests expected to be absent' ); + ok( !exists $res->{running_tests}, 'list of running tests expected to be absent' ); + ok( !exists $res->{finished_tests}, 'list of finished tests to be absent' ); - subtest 'unknown batch (get_batch_job_result)' => sub { - my $unknown_batch = 10; - dies_ok { - $rpcapi->get_batch_job_result( { batch_id => $unknown_batch } ); - } 'getting results for an unknown batch_id should die'; - my $res = $@; - is( $res->{error}, 'Zonemaster::Backend::Error::ResourceNotFound', 'correct error type' ); - is( $res->{message}, 'Unknown batch', 'correct error message' ); - is( $res->{data}->{batch_id}, $unknown_batch, 'correct data type returned' ); }; subtest 'unknown batch (batch_status)' => sub { @@ -227,12 +206,6 @@ subtest 'batch with several domains' => sub { is( $res, 1, 'correct batch job id returned' ); - # "get_batch_job_result deprecated to be removed by v2025.2 - $res = $rpcapi->get_batch_job_result( { batch_id => 1 } ); - - is( $res->{nb_running}, @domains, 'correct number of runninng tests' ); - is( $res->{nb_finished}, 0, 'correct number of finished tests' ); - # No lists of test IDs requested $res = $rpcapi->batch_status( { batch_id => 1 } );