From: Rogan Hamby Date: Wed, 1 May 2019 19:47:15 +0000 (-0400) Subject: Merge branch 'master' of git.esilibrary.com:migration-tools while adding mig reporter... X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=1b92214d69a55533daaddbbb152d784af894c547;hp=bc721db6d7e1f19890d1b4d8ea320bbcba82461a Merge branch 'master' of git.esilibrary.com:migration-tools while adding mig reporter report for copy alerts --- diff --git a/mig-bin/mig-dump b/mig-bin/mig-dump new file mode 100755 index 0000000..57edeab --- /dev/null +++ b/mig-bin/mig-dump @@ -0,0 +1,88 @@ +#!/usr/bin/perl + +############################################################################### +=pod + +=head1 NAME + +mig-dump + +A wrapper around the pg_dump command that saves a table in the mig schema with a time stamp in the working directory. + +=head1 SYNOPSIS + +B [arguments...] + +=cut + +############################################################################### + +use strict; +use warnings; + +use Env qw( + HOME PGHOST PGPORT PGUSER PGDATABASE MIGSCHEMA + MIGBASEWORKDIR MIGBASEGITDIR MIGGITDIR MIGWORKDIR +); +use Pod::Usage; +use Switch; +use Cwd 'abs_path'; +use Cwd qw(getcwd); +use FindBin; +my $mig_bin = "$FindBin::Bin/"; +use lib "$FindBin::Bin/"; +use Mig; +use open ':encoding(utf8)'; + +pod2usage(-verbose => 2) if defined $ARGV[0] && $ARGV[0] eq '--help'; +pod2usage(-verbose => 1) if ! $ARGV[1]; + +my $fh; +my $outfile; + +my $table; +my $next_arg_is_table; + +foreach my $arg (@ARGV) { + if ($arg eq '--table') { + $next_arg_is_table = 1; + next; + } + if ($next_arg_is_table) { + $table = $arg; + $next_arg_is_table = 0; + next; + } +} + +my $outfilewpath = create_dumpfile_name($table); + +my $syscmd = 'pg_dump --format plain --data-only --file ' . $outfilewpath . ' --table ' . $MIGSCHEMA . '.' . $table . ' ' . $PGUSER; + +print "pgdump command: \n"; +print "$syscmd\n"; + +system($syscmd); + +####### beyond here be functions + +sub create_dumpfile_name { + my $table_name = shift; + $table_name =~ s/\./_/; + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + $year += 1900; + my $date = $year . '-' . $mon . '-' . $mday; + my $dump_file = $table_name . ' ' . $date . '.pg'; + $dump_file =~ s/ /_/g; + $dump_file = $MIGGITDIR . $dump_file; + print "$dump_file \n"; + return $dump_file; +} + +sub abort { + my $msg = shift; + print STDERR "$0: $msg", "\n"; + exit 1; +} + + diff --git a/mig-xml/evergreen_full_system.xml b/mig-xml/evergreen_full_system.xml index 23cabe1..e972f6a 100644 --- a/mig-xml/evergreen_full_system.xml +++ b/mig-xml/evergreen_full_system.xml @@ -23,9 +23,9 @@ circs_by_duration circs 0 - Circulations by Duration, Fine and Max Fine + Circulations by Duration, Fine and Max Fine Rules Count of Circs.Duration.Fine.Max Fine - SELECT COUNT(id), duration, recurring_fine, max_fine FROM action.circulation GROUP BY 2, 3, 4 ORDER BY 2, 3, 4 + SELECT COUNT(id), duration_rule, recurring_fine_rule, max_fine_rule FROM action.circulation GROUP BY 2, 3, 4 ORDER BY 2, 3, 4 @@ -34,7 +34,7 @@ 0 Circulations by Rules and Patron Group Count of Circs.Duration.Fine.Max Fine.User Group - SELECT COUNT(acirc.id), acirc.duration, acirc.recurring_fine, acirc.max_fine, pgt.name FROM action.circulation acirc JOIN actor.usr au ON au.id = acirc.usr JOIN permission.grp_tree pgt ON pgt.id = au.profile + SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, pgt.name FROM action.circulation acirc JOIN actor.usr au ON au.id = acirc.usr JOIN permission.grp_tree pgt ON pgt.id = au.profile GROUP BY 2, 3, 4, 5 ORDER BY 2, 3, 4, 5 @@ -44,7 +44,7 @@ 0 Circulations by Rules and Circulation Modifier Count of Circs.Duration.Fine.Max Fine.Circulation Modifier - SELECT COUNT(acirc.id), acirc.duration, acirc.recurring_fine, acirc.max_fine, ac.circ_modifier FROM action.circulation acirc JOIN asset.copy ac ON ac.id = acirc.target_copy + SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, ac.circ_modifier FROM action.circulation acirc JOIN asset.copy ac ON ac.id = acirc.target_copy GROUP BY 2, 3, 4, 5 ORDER BY 2, 3, 4, 5 @@ -54,7 +54,7 @@ 0 Circulations by Rules and Org Unit Count of Circs.Duration.Fine.Max Fine.Library Branch - SELECT COUNT(acirc.id), acirc.duration, acirc.recurring_fine, acirc.max_fine, aou.name FROM action.circulation acirc JOIN actor.org_unit aou ON aou.id = acirc.circ_lib GROUP BY 2, 3, 4, 5 ORDER BY 2, 3, 4, 5 + SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, aou.name FROM action.circulation acirc JOIN actor.org_unit aou ON aou.id = acirc.circ_lib GROUP BY 2, 3, 4, 5 ORDER BY 2, 3, 4, 5 diff --git a/mig-xml/evergreen_staged_report.xml b/mig-xml/evergreen_staged_report.xml index 93e0608..6726a82 100644 --- a/mig-xml/evergreen_staged_report.xml +++ b/mig-xml/evergreen_staged_report.xml @@ -102,7 +102,7 @@ 0 Migrated Circulations by Duration, Fine and Max Fine Count of Circs.Duration.Fine.Max Fine.Migrated - SELECT COUNT(id), duration, recurring_fine, max_fine, x_migrate::TEXT FROM action_circulation_legacy WHERE x_migrate = TRUE GROUP BY 2, 3, 4, 5 + SELECT COUNT(id), duration_rule, recurring_fine_rule, max_fine_rule, x_migrate::TEXT FROM action_circulation_legacy WHERE x_migrate = TRUE GROUP BY 2, 3, 4, 5 @@ -111,7 +111,7 @@ 1 Circulations by Duration, Fine and Max Fine Count of Circs.Duration.Fine.Max Fine - SELECT COUNT(id), duration, recurring_fine, max_fine FROM action_circulation GROUP BY 2, 3, 4 ORDER BY 2, 3, 4 + SELECT COUNT(id), duration_rule, recurring_fine_rule, max_fine_rule FROM action_circulation GROUP BY 2, 3, 4 ORDER BY 2, 3, 4 @@ -120,7 +120,7 @@ 0 Circulations by Rules and Patron Group Count of Circs.Duration.Fine.Max Fine.User Group.Matchpoints - SELECT COUNT(acirc.id), acirc.duration, acirc.recurring_fine, acirc.max_fine, pgt.name, x.buildrows FROM action_circulation_legacy acirc JOIN actor.usr au ON au.id = acirc.usr JOIN permission.grp_tree pgt ON pgt.id = au.profile JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM action_circulation_legacy acirc WHERE acirc.x_migrate = TRUE) x ON x.id = acirc.id WHERE acirc.x_migrate = TRUE GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6 + SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, pgt.name, x.buildrows FROM action_circulation_legacy acirc JOIN actor.usr au ON au.id = acirc.usr JOIN permission.grp_tree pgt ON pgt.id = au.profile JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM action_circulation_legacy acirc WHERE acirc.x_migrate = TRUE) x ON x.id = acirc.id WHERE acirc.x_migrate = TRUE GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6 @@ -129,7 +129,7 @@ 1 Circulations by Rules and Patron Group Count of Circs.Duration.Fine.Max Fine.User Group.Matchpoints - SELECT COUNT(acirc.id), acirc.duration, acirc.recurring_fine, acirc.max_fine, pgt.name, x.buildrows FROM action_circulation acirc JOIN actor.usr au ON au.id = acirc.usr JOIN permission.grp_tree pgt ON pgt.id = au.profile JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM action_circulation acirc) x ON x.id = acirc.id GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6 + SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, pgt.name, x.buildrows FROM action_circulation acirc JOIN actor.usr au ON au.id = acirc.usr JOIN permission.grp_tree pgt ON pgt.id = au.profile JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM action_circulation acirc) x ON x.id = acirc.id GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6 @@ -138,7 +138,7 @@ 0 Circulations by Rules and Circulation Modifier Count of Circs.Duration.Fine.Max Fine.Circulation Modifier.Matchpoints - SELECT COUNT(acirc.id), acirc.duration, acirc.recurring_fine, acirc.max_fine, ac.circ_modifier, x.buildrows FROM action_circulation_legacy acirc JOIN asset.copy ac ON ac.id = acirc.target_copy JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM action_circulation_legacy acirc WHERE acirc.x_migrate = TRUE) x ON x.id = acirc.id WHERE acirc.x_migrate = TRUE GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6 + SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, ac.circ_modifier, x.buildrows FROM action_circulation_legacy acirc JOIN asset.copy ac ON ac.id = acirc.target_copy JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM action_circulation_legacy acirc WHERE acirc.x_migrate = TRUE) x ON x.id = acirc.id WHERE acirc.x_migrate = TRUE GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6 @@ -147,7 +147,7 @@ 1 Circulations by Rules and Circulation Modifier Count of Circs.Duration.Fine.Max Fine.Circulation Modifier.Matchpoints - SELECT COUNT(acirc.id), acirc.duration, acirc.recurring_fine, acirc.max_fine, ac.circ_modifier, x.buildrows FROM action_circulation acirc JOIN asset.copy ac ON ac.id = acirc.target_copy JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM action_circulation acirc) x ON x.id = acirc.id + SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, ac.circ_modifier, x.buildrows FROM action_circulation acirc JOIN asset.copy ac ON ac.id = acirc.target_copy JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM action_circulation acirc) x ON x.id = acirc.id GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6 @@ -157,7 +157,7 @@ 0 Circulations by Rules and Org Unit Count of Circs.Duration.Fine.Max Fine.Library Branch - SELECT COUNT(acirc.id), acirc.duration, acirc.recurring_fine, acirc.max_fine, aou.name FROM action_circulation_legacy acirc JOIN actor.org_unit aou ON aou.id = acirc.circ_lib WHERE acirc.x_migrate = TRUE GROUP BY 2, 3, 4, 5 ORDER BY 2, 3, 4, 5 + SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, aou.name FROM action_circulation_legacy acirc JOIN actor.org_unit aou ON aou.id = acirc.circ_lib WHERE acirc.x_migrate = TRUE GROUP BY 2, 3, 4, 5 ORDER BY 2, 3, 4, 5 @@ -166,7 +166,7 @@ 1 Circulations by Rules and Org Unit Count of Circs.Duration.Fine.Max Fine.Library Branch - SELECT COUNT(acirc.id), acirc.duration, acirc.recurring_fine, acirc.max_fine, aou.name FROM action_circulation acirc JOIN actor.org_unit aou ON aou.id = acirc.circ_lib GROUP BY 2, 3, 4, 5 ORDER BY 2, 3, 4, 5 + SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, aou.name FROM action_circulation acirc JOIN actor.org_unit aou ON aou.id = acirc.circ_lib GROUP BY 2, 3, 4, 5 ORDER BY 2, 3, 4, 5