X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=mig-bin%2Fmig-reporter;h=8e9e81d56e4e0bf23c22b0e41d414afeb7d6d42c;hp=adeefe2d25cb0daf4e68ca7d29d540929dc4cc32;hb=8ac648a9a0d7bf9f2df03ec8fc952d088fe0d740;hpb=11896d6209f169cbabe9fb6cfc944695b47a1425 diff --git a/mig-bin/mig-reporter b/mig-bin/mig-reporter index adeefe2..8e9e81d 100755 --- a/mig-bin/mig-reporter +++ b/mig-bin/mig-reporter @@ -1,5 +1,40 @@ #!/usr/bin/perl +############################################################################### +=pod + +=item B --analyst "Analyst Name" --report_title "Report Title" + +Generates an asciidoc file in the git working directory that can be converted to +any appropriate format. The analyst and report parameters are required. + +Optional parameters are : + +--added_page_title and --added_page_file + +If one is used both must be. The added page file can be plain text or asciidoc. This +adds an extra arbitrary page of notes to the report. Mig assumes the page file is in the mig git directory. + +--tags + +This will define a set of tags to use, if not set it will default to Circs, +Holds, Actors, Bibs, Assets & Money. + +--debug + +Gives more information about what is happening. + +--reports_xml + +Allows you to override the default evergreen_staged_report.xml in the mig-xml folder. + + +=back + +=cut + +############################################################################### + use strict; use warnings; @@ -20,6 +55,7 @@ use Mig; use open ':encoding(utf8)'; pod2usage(-verbose => 2) if defined $ARGV[0] && $ARGV[0] eq '--help'; +pod2usage(-verbose => 1) if ! $ARGV[1]; my $analyst; my $next_arg_is_analyst; @@ -36,6 +72,7 @@ my $next_arg_is_added_page_file; my $i = 0; my $parser = XML::LibXML->new(); my $lines_per_page = 42; +my $debug_flag = 0; foreach my $arg (@ARGV) { if ($arg eq '--report_title') { @@ -92,6 +129,10 @@ foreach my $arg (@ARGV) { $next_arg_is_added_page_file = 0; next; } + if ($arg eq '--debug') { + $debug_flag = 1; + next; + } } if (!defined $tags) {$tags = 'circs.holds.actors.bibs.assets.money'}; @@ -102,7 +143,6 @@ my $mig_path = abs_path($0); $mig_path =~ s|[^/]+$||; if (!defined $reports_xml) { $reports_xml = $mig_path . '../mig-xml/evergreen_staged_report.xml'; } else { $reports_xml = $mig_path . '/../mig-xml/' . $reports_xml; } -print "$reports_xml \n"; my $dom = $parser->parse_file($reports_xml); if (defined $added_page_file or defined $added_page_title) { @@ -146,7 +186,7 @@ $tags = lc($tags); my @report_tags = split(/\./,$tags); foreach my $t (@report_tags) { print "\n\n=========== Starting to process tag $t\n"; - print "==========================================\n"; + print "==========================================\n\n"; my @asset_files; foreach my $asset ($dom->findnodes('//asset')) { @@ -168,7 +208,7 @@ foreach my $t (@report_tags) { my $linecount = $lines_per_page; my $r; - my @asset_files; + undef @asset_files; foreach my $asset ($dom->findnodes('//asset')) { if (index($asset->findvalue('./tag'),$t) != -1) { push @asset_files, $asset->findvalue('./file'); @@ -190,15 +230,15 @@ foreach my $t (@report_tags) { my $check_tables0; my $check_tables1; - print "\nchecking for $rname ... "; - %report0 = find_report($dom,$t,$rname,'0'); - $check_tables0 = check_table($report0{query},$MIGSCHEMA); + if ($debug_flag == 1) {print "\nchecking for $rname ... ";} + %report0 = find_report($dom,$t,$rname,'0',$debug_flag); + $check_tables0 = check_table($report0{query},$MIGSCHEMA,$debug_flag,$rname); if ($check_tables0 == 1) { $r = print_query($fh,%report0); } else { - %report1 = find_report($dom,$t,$rname,'1'); + %report1 = find_report($dom,$t,$rname,'1',$debug_flag); if (defined $report1{query}) { - $check_tables1 = check_table($report1{query},$MIGSCHEMA); + $check_tables1 = check_table($report1{query},$MIGSCHEMA,$debug_flag,$rname); if ($check_tables1 == 1) {$r = print_query($fh,%report1);} } } @@ -215,12 +255,13 @@ sub find_report { my $tag = shift; my $name = shift; my $iteration = shift; + my $debug_flag = shift; my %report; - print "iteration $iteration "; + if ($debug_flag == 1) {print "iteration $iteration ";} foreach my $node ($dom->findnodes('//report')) { if ($node->findvalue('./tag') =~ $tag and $node->findvalue('./iteration') eq $iteration and $node->findvalue('./name') eq $name) { - print "succeeded ... \n"; + if ($debug_flag == 1) {print "succeeded ... \n";} %report = ( name => $node->findvalue('./name'), report_title => $node->findvalue('./report_title'), @@ -233,7 +274,7 @@ sub find_report { return %report; } } - print "failed ... \n"; + if ($debug_flag == 1) {print "failed ... \n";} return %report = ( name => "eaten by grue" ); @@ -279,6 +320,10 @@ sub write_title_page { sub check_table { my $query = shift; my $MIGSCHEMA = shift; + my $debug_flag = shift; + my $report_name = shift; + + if ($debug_flag == 1) {print "$query\n";} my $i; my $return_flag = 1; @@ -295,19 +340,19 @@ sub check_table { } $i--; } - print "checking tables ... "; + if ($debug_flag == 1) {print "checking tables ... ";} $i = 0; foreach my $table (@tables) { - $table =~ s/\)//g; - $table =~ s/\prepare($query); $sth->execute();