Skip to content
Snippets Groups Projects
Select Git revision
  • f6fc75db931be95bbe730576d013c464536a1de3
  • master default protected
  • diag
  • version1.3-archivematica
  • version1.2-archivematica
  • version1.1-archivematica
  • version1.0-archivematica
  • version1.0-rosetta
8 results

TA.pm

Blame
  • report.pm 9.30 KiB
    package SLUB::LZA::TA::Command::report;
    use SLUB::LZA::TA -command;
    use v5.36;
    use SLUB::LZA::TA::Archivematica::Elasticsearch;
    use SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery;
    use SLUB::LZA::TA::Output;
    
    use Date::Calc qw(Date_to_Time Today Add_Delta_YM Add_Delta_YMD Day_of_Week);
    use namespace::autoclean -except => qr{SLUB::LZA::TA::.*};
    
    # VERSION
    
    # ABSTRACT: search IEs module for ta-tool
    
    sub abstract {"print AIP reports about Archival Information System (AIS)";}
    
    my $description=<<"DESCR";
    Ask an AIS for some statistics about AIPs.
    
    Examples:
    
      * Report statistics of AIPs last month for workflow Kitodo
        '$0 report --monthly --workflow Kitodo'
      * Report statistics of AIPs last year as RSV
        '$0 report --yearly'
    
    A printable PDF version could be generated using ff. commands:
        '$0 report | asciidoctor-pdf - > report.pdf'
    
    
    DESCR
    
    sub description {
        "$description"
    }
    sub opt_spec {
        return (
            [ 'debug' => 'enable user agent debug output' ],
            [],
            [ 'datemode' => hidden => {
                one_of => [
                    [ 'daily|d'   => 'report based on last day'],
                    [ 'weekly|W'  => 'report based on last week'],
                    [ 'monthly|m' => 'report based on last month' ],
                    [ 'yearly|y'  => 'report based on last year' ],
                ]
              }
            ],
            [ 'workflow|w=s' => 'LZA internal workflow name'],
            [],
            [ 'help|h', 'print usage message and exit', { shortcircuit => 1 } ],
            [ 'version|v', 'print version information', { shortcircuit => 1 } ],
        );
    }
    sub validate_args {
        my ($self, $opt, $args) = @_;
        # no args allowed but options!
        $self->usage_error("No args allowed") if @$args;
        my ($cyear, $cmonth, $cday) = Today();
        my ($from_year, $from_month, $from_day);
        my ($to_year, $to_month, $to_day);
        if (exists $opt->{daily}) {
            ($from_year, $from_month, $from_day) = Add_Delta_YMD($cyear, $cmonth, $cday, 0, 0, -1);
            ($to_year, $to_month, $to_day) = ($from_year, $from_month, $from_day);
        } elsif (exists $opt->{weekly}) {
            ($from_year, $from_month, $from_day) = Add_Delta_YMD($cyear, $cmonth, $cday, 0, 0, -Day_of_Week($cyear, $cmonth, $cday)-6);
            ($to_year, $to_month, $to_day) = Add_Delta_YMD($from_year, $from_month, $from_day, 0, 0, 6);
        } elsif (exists $opt->{monthly}) {
            ($from_year, $from_month, $from_day) = Add_Delta_YM($cyear, $cmonth, 1, 0, -1);
            ($to_year, $to_month, $to_day) = Add_Delta_YMD($from_year, $from_month, $from_day, 0, 1, -1);