From 676609b2b25e33675d4080b9aba468b20e2d8d67 Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Thu, 13 Jun 2024 12:37:33 +0200
Subject: [PATCH] - refactoring, unpacked @_ to use modern perl

---
 lib/SLUB/LZA/TA/Command/report.pm | 13 +++++--------
 lib/SLUB/LZA/TA/Command/search.pm | 10 ++++------
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/lib/SLUB/LZA/TA/Command/report.pm b/lib/SLUB/LZA/TA/Command/report.pm
index fbc8d05..0a5d93b 100644
--- a/lib/SLUB/LZA/TA/Command/report.pm
+++ b/lib/SLUB/LZA/TA/Command/report.pm
@@ -271,9 +271,8 @@ PAINLESS
     return $aips_response;
 }
 
-sub get_ldp_projects { ## no critic (CognitiveComplexity::ProhibitExcessCognitiveComplexity)
-    my ($self, $opt, $args) = @_;
-    my $query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_ldpprojects_query(@_);
+sub get_ldp_projects ($self, $opt, $args) { ## no critic (CognitiveComplexity::ProhibitExcessCognitiveComplexity)
+    my $query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_ldpprojects_query($self, $opt, $args);
     my $response = SLUB::LZA::TA::Archivematica::Elasticsearch::query_elasticsearch(
         $SLUB::LZA::TA::config{elasticsearch_protocol},
         $SLUB::LZA::TA::config{elasticsearch_host},
@@ -303,8 +302,7 @@ sub get_ldp_projects { ## no critic (CognitiveComplexity::ProhibitExcessCognitiv
     return @ret;
 }
 
-sub get_filestypes_by_aips {
-    my ($self, $opt, $args) = @_;
+sub get_filestypes_by_aips($self, $opt, $args) {
     my $aips_query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_aip_query($opt);
     $aips_query->{"_source"} = {
         "includes" => 'uuid'
@@ -464,14 +462,13 @@ sub set_ldpflavour_results_for_filetype($self, $opt, $args, $results_ref, $newha
     return 1;
 }
 
-sub execute {
-    my ($self, $opt, $args) = @_;
+sub execute($self, $opt, $args) {
     my %results;
     $results{date} = sprintf("%04u-%02u-%02u", Today());
     $results{package} = __PACKAGE__;
     $results{from} = $opt->{creationdate_epochs}->{from_string};
     $results{to} = $opt->{creationdate_epochs}->{to_string};
-    my @ldp_projects = ($opt->{with_ldp}) ? get_ldp_projects(@_) : ();
+    my @ldp_projects = ($opt->{with_ldp}) ? get_ldp_projects($self, $opt, $args) : ();
     foreach my $aip_state (AIPSTATE) {
         my %newhash = %{$opt};
         filtered_set_for_aipstate($aip_state, \%newhash);
diff --git a/lib/SLUB/LZA/TA/Command/search.pm b/lib/SLUB/LZA/TA/Command/search.pm
index 1bea181..c4cb38a 100644
--- a/lib/SLUB/LZA/TA/Command/search.pm
+++ b/lib/SLUB/LZA/TA/Command/search.pm
@@ -174,11 +174,10 @@ sub validate_args($self, $opt, $args) { ## no critic qw(CognitiveComplexity::Pro
 }
 
 
-sub find_aips_by_file_pronom_id {
-    my ($self, $opt, $args) = @_;
+sub find_aips_by_file_pronom_id($self, $opt, $args) {
     # index aipfiles needed
     # find all AIPs where pronom-id like XXX
-    my $files_query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_files_query(@_);
+    my $files_query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_files_query($self, $opt, $args);
     my $files_response = SLUB::LZA::TA::Archivematica::Elasticsearch::query_elasticsearch(
         $SLUB::LZA::TA::config{elasticsearch_protocol},
         $SLUB::LZA::TA::config{elasticsearch_host},
@@ -198,15 +197,14 @@ sub find_aips_by_file_pronom_id {
     return keys %aips;
 }
 
-sub execute {
-    my ($self, $opt, $args) = @_;
+sub execute($self, $opt, $args) {
     my $aips_query;
     my $aips_response;
     #p($opt);
     if (exists $opt->{format} and $opt->{format} eq 'pronom_id') {
         $aips_query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_aip_query($opt);
         # replace AIP query with all match
-        my @aips = find_aips_by_file_pronom_id(@_);
+        my @aips = find_aips_by_file_pronom_id($self, $opt, $args);
         $aips_query->{query}->{bool}->{must}->{terms}->{uuid} = \@aips;
     } else {
         # only index aips needed
-- 
GitLab