mig-reporter can now output excel and has some mapping sheets defined
authorRogan Hamby <rhamby@esilibrary.com>
Tue, 20 Mar 2018 19:19:05 +0000 (15:19 -0400)
committerRogan Hamby <rhamby@esilibrary.com>
Tue, 20 Mar 2018 19:19:05 +0000 (15:19 -0400)
mig-bin/mig-reporter
mig-xml/excel_mapping_reports.xml [new file with mode: 0644]

index 8e9e81d..7f223f9 100755 (executable)
@@ -28,6 +28,9 @@ Gives more information about what is happening.
 
 Allows you to override the default evergreen_staged_report.xml in the mig-xml folder.
 
+--excel_output or --excel
+
+Pushes output to an Excel file instead of asciidoc file. 
 
 =back
 
@@ -45,6 +48,7 @@ use Env qw(
     HOME PGHOST PGPORT PGUSER PGDATABASE MIGSCHEMA
     MIGBASEWORKDIR MIGBASEGITDIR MIGGITDIR MIGWORKDIR
 );
+use Excel::Writer::XLSX;
 use Pod::Usage;
 use Switch;
 use Cwd 'abs_path';
@@ -69,10 +73,13 @@ my $added_page_title;
 my $next_arg_is_added_page_title;
 my $added_page_file;
 my $next_arg_is_added_page_file;
+my $excel_output = 0;
 my $i = 0;
 my $parser = XML::LibXML->new();
 my $lines_per_page = 42;
 my $debug_flag = 0;
+my $workbook;
+my $fh;
 
 foreach my $arg (@ARGV) {
     if ($arg eq '--report_title') {
@@ -129,6 +136,10 @@ foreach my $arg (@ARGV) {
         $next_arg_is_added_page_file = 0;
         next;
     }
+    if ($arg eq '--excel_output' or $arg eq '--excel') {
+        $excel_output = 1;
+        next;
+    }
     if ($arg eq '--debug') {
         $debug_flag = 1;
         next;
@@ -136,13 +147,15 @@ foreach my $arg (@ARGV) {
 }
 
 if (!defined $tags) {$tags = 'circs.holds.actors.bibs.assets.money'};
-if (!defined $analyst) { abort('--analyst must be supplied'); }
 if (!defined $report_title) { abort('--report_title must be supplied'); }
+if ($excel_output == 0 and !defined $analyst) { abort('--analyst must be supplied'); }
 
 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; }
+if (!defined $reports_xml) { 
+    if ($excel_output == 0) { $reports_xml = $mig_path . '../mig-xml/evergreen_staged_report.xml'; } 
+        else { $reports_xml = $mig_path . '../mig-xml/excel_mapping_reports.xml'; } 
+    } else { $reports_xml = $mig_path . '/../mig-xml/' . $reports_xml; }
 my $dom = $parser->parse_file($reports_xml);
 
 if (defined $added_page_file or defined $added_page_title) {
@@ -151,12 +164,15 @@ if (defined $added_page_file or defined $added_page_title) {
 if (defined $added_page_file) { $added_page_file = $MIGGITDIR . $added_page_file; }
 
 my $dbh = Mig::db_connect();
-my $report_file = create_report_name($report_title);
+my $report_file = create_report_name($report_title,$excel_output);
 $report_file = $MIGGITDIR . $report_file;
 
-open(my $fh, '>', $report_file) or abort("Could not open output file!");
-
-write_title_page($report_title,$fh,$analyst);
+if ($excel_output == 1) {
+    $workbook = Excel::Writer::XLSX->new( $report_file );
+} else {
+    open($fh, '>', $report_file) or abort("Could not open output file!");
+    write_title_page($report_title,$fh,$analyst);
+};
 
 if (defined $added_page_file and defined $added_page_title) { 
     print $fh "<<<\n";
@@ -204,7 +220,7 @@ foreach my $t (@report_tags) {
     print $fh "<<<\n";
     }
 
-    print_section_header(ucfirst($t),$fh);
+    if ($excel_output == 0) { print_section_header(ucfirst($t),$fh); }
     my $linecount = $lines_per_page;
     my $r;
 
@@ -219,34 +235,39 @@ foreach my $t (@report_tags) {
     foreach my $report ($dom->findnodes('//report')) {
         if (index($report->findvalue('./tag'),$t) != -1 and $report->findvalue('./iteration') eq '0') {
             push @report_names, $report->findvalue('./name');
+            if ($excel_output == 1) { print_query_to_excel($workbook,$report); }
         }
     }
 
     #only has one level of failover now but could change to array of hashes and loops
     #but this keeps it simple and in practice I haven't needed more than two
-    foreach my $rname (@report_names) {
-        my %report0;
-        my %report1;
-        my $check_tables0;
-        my $check_tables1;
-
-        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',$debug_flag);
-        if (defined $report1{query}) {
-            $check_tables1 = check_table($report1{query},$MIGSCHEMA,$debug_flag,$rname);
-            if ($check_tables1 == 1) {$r = print_query($fh,%report1);}    
+    
+
+    if ($excel_output == 0) {
+        foreach my $rname (@report_names) {
+            my %report0;
+            my %report1;
+            my $check_tables0;
+            my $check_tables1;
+
+            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',$debug_flag);
+                if (defined $report1{query}) {
+                    $check_tables1 = check_table($report1{query},$MIGSCHEMA,$debug_flag,$rname);
+                    if ($check_tables1 == 1) { $r = print_query($fh,%report1); }
+                }
             }
         }
     }
 }
 
 print "\n";
-close $fh;
+
+if ($excel_output eq 1) { $workbook->close(); } 
+    else { close $fh; }
 
 ############ end of main logic
 
@@ -283,19 +304,25 @@ sub find_report {
 sub print_section_header {
     my $t = shift;
     my $fh = shift;
+
     $t =~ s/_/ /g;
     #$t =~ s/(\w+)/\u$1/g;;
     print $fh "<<<\n";
     print $fh "== $t Reports\n";
+    return;
 }
 
 sub create_report_name {
     my $rt = shift;
+    my $excel_output = shift;
+
     my @abbr = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
     $year += 1900;
     my $date = $year . '_' . $abbr[$mon] . '_' . $mday;
-    my $report_file = $rt . ' ' . $date . '.asciidoc';
+    my $report_file;
+    if ($excel_output == 0) { $report_file = $rt . ' ' . $date . '.asciidoc'; }
+        else { $report_file = $rt . ' ' . $date . '.xlsx'; }
     $report_file =~ s/ /_/g;
     return $report_file;
 }
@@ -370,7 +397,7 @@ sub check_table {
         }
     }
     if ($return_flag == 1 and $debug_flag == 1) {print "succeeded ...\n";}
-    if ($return_flag == 0) {print "!!!!! a table failed the find test for report $report_name\n\n";}
+    if ($return_flag == 0) {print "! a table failed the find test for report $report_name\n\n";}
     return $return_flag;
 }
 
@@ -425,6 +452,67 @@ sub print_query {
     print "successfully wrote output for $report{name}.\n\n";
 }
 
+sub print_query_to_excel {
+    my $workbook = shift;
+    my $report = shift;
+
+    my $header_format = $workbook->add_format( bold => 1, color => 'green', size => 16);
+    my $note_format = $workbook->add_format( bold => 1, color => 'red', size => 14);
+
+    my $query = $report->findvalue('./query');
+    my $title = $report->findvalue('./report_title');
+    my $headings = $report->findnodes('./heading');
+
+    my $sth = $dbh->prepare($query);
+    $sth->execute();
+
+    my $worksheet = $workbook->add_worksheet( $title );
+    my $cell = "";
+    my $col = "";
+
+    my @h = split(/\./,$headings);
+    my $h_length = @h;
+    my $h_count = 1;
+    while ($h_count <= $h_length) {
+        $col = give_column($h_count-1);
+        $cell = $col . '1';
+        $worksheet->write($cell,$h[$h_count-1],$header_format);
+        $h_count++;
+    }
+    my $cur_row = 1;
+    while (my @row = $sth->fetchrow_array) {
+            $cur_row++;
+            my $row_length = @row;
+            my $r = 1;
+            print Dumper(@row);
+            while ($r <= $row_length) {
+                if (! defined $row[$r-1] ) {
+                    $row[$r-1] = 'none';
+                }
+                $col = give_column($r-1);
+                $cell = $col . $cur_row;
+                $worksheet->write($cell,$row[$r-1]);
+                $r++;
+            }
+        }
+    $cur_row = $cur_row + 2;
+    $cell = "A" . "$cur_row"; 
+    $worksheet->write($cell,$report->findvalue('./note'),$note_format);
+    print "Printed Query for $title.\n";
+}
+
+sub give_column {
+    my $i = shift;
+    my $col = "";
+
+    do {
+        $col .= chr( ( $i % 26 ) + ord('A') );
+        $i = int( $i / 26 ) - 1;
+    } while ( $i >= 0 );
+
+    return scalar reverse $col;
+}
+
 sub abort {
     my $msg = shift;
     print STDERR "$0: $msg", "\n";
diff --git a/mig-xml/excel_mapping_reports.xml b/mig-xml/excel_mapping_reports.xml
new file mode 100644 (file)
index 0000000..397f214
--- /dev/null
@@ -0,0 +1,756 @@
+<reports_file>
+<!-- sample reports entry
+    <report>
+        <name>name of report</name>
+        <iteration value='0' /> which version, the first version to run is 0, first backup is 1, then so on
+        <tag>money</tag>  arbitrary tags, each should go in separate tag
+        <report_title>Migrated Billings</report_title>  title used in the asciidoc output
+        <heading column='1'>Number of Billings.Migrated.Total</heading> period delimited 
+        <query>SELECT COUNT(id),x_migrate,SUM(amount) FROM money_billing_legacy GROUP BY 2;</query>  query itself, will be replaced
+        <note>Arbitrary note that can be included in the entries.</note>
+    </report>
+-->
+
+   <!-- evergreen -->
+
+    <report>
+        <name>evg_asset_copy_statuses</name>
+        <report_title>Statuses</report_title>
+        <tag>evergreen</tag>
+        <iteration>0</iteration>
+        <heading>Copy Count.Migrating Status.New Evergreen Status.Notes</heading>
+        <query>SELECT COUNT(ac.l_id), cs.l_name FROM asset_copy_legacy ac JOIN config_copy_status_legacy cs ON cs.l_id = ac.l_status GROUP BY 2 ORDER BY 2</query>
+        <note>You only need to fill this sheet out if you use custom statuses that need to be migrated.</note>
+    </report>
+
+    <report>
+        <name>evg_asset_circ_mods</name>
+        <report_title>Circulation Modifiers</report_title>
+        <tag>evergreen</tag>
+        <iteration>0</iteration>
+        <heading>Copy Count.Migrating Circ Mod.New Circ Mod.Notes</heading>
+        <query>SELECT COUNT(ac.l_id), ac.l_circ_modifier FROM asset_copy_legacy ac GROUP BY 2 ORDER BY 2</query>
+    </report>
+
+    <report>
+        <name>evg_asset_copy_locs</name>
+        <report_title>Copy Locations</report_title>
+        <tag>evergreen</tag>
+        <iteration>0</iteration>
+        <heading>Count.Library.Migrating Copy Location.New Copy Location.Notes</heading>
+        <query>SELECT COUNT(ac.l_id), aou.l_name, acl.l_name FROM asset_copy_location_legacy acl JOIN actor_org_unit_legacy aou ON aou.l_id = acl.l_owning_lib JOIN asset_copy_legacy ac ON ac.l_location = acl.l_id GROUP BY 2, 3 ORDER BY 2, 3</query>
+        <note>Any locations not mapped can be moved over as their existing locations.</note>
+    </report>
+
+   <report>
+        <name>evg_permission_grps</name>
+        <report_title>Permission Groups</report_title>
+        <tag>evergreen</tag>
+        <iteration>0</iteration>
+        <heading>Count.Migrating Permission Group.New Permission Group.Notes</heading>
+        <query>SELECT COUNT(au.l_id), pgt.l_name FROM actor_usr_legacy au JOIN permission_grp_tree_legacy pgt ON pgt.l_id = au.l_profile GROUP BY 2 ORDER BY 2</query>
+    </report>
+
+    <!-- tlc -->
+    <report>
+        <name>tlc_load_branches_list</name>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <report_title>Branches Present in Extract</report_title>
+        <heading>Name.Evergreen Org Unit.Notes</heading>
+        <query>SELECT l_name FROM ctbranches_tsv_clean ORDER BY 1</query>
+    </report>
+
+    <report>
+        <name>tlc_load_asset_notes</name>
+        <report_title>Item Notes</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Note Type.Notes</heading>
+        <query>SELECT COUNT(l_itemcomment), 'Item Comments' FROM ititeminformation_tsv_clean WHERE l_itemcomment IS NOT NULL GROUP BY 2
+               UNION ALL SELECT COUNT(l_physicalcondition), 'Condition Notes' FROM ctlocitem_tsv_clean WHERE l_physicalcondition IS NOT NULL GROUP BY 2
+               UNION ALL SELECT COUNT(l_checkinoutnote), 'Circ Notes' FROM ctlocitem_tsv_clean WHERE l_checkinoutnote IS NOT NULL GROUP BY 2
+         </query>
+    </report>
+
+    <report>
+        <name>tlc_load_asset_in_house_use</name>
+        <report_title>Copies With In House Uses</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Copy Count.Sum of In House Uses.Do Not Migrate</heading>
+        <query>SELECT COUNT(l_totalinhouseuses), SUM(l_totalinhouseuses::INTEGER) FROM ititeminformation_tsv_clean WHERE l_totalinhouseuses != '0'</query>
+        <note>TLC doesn't have dates recorded for in house use so these can only be migrated as date of migration or we can not migrate them.</note>
+    </report>
+
+    <report>
+        <name>tlc_load_asset_holdings_codes</name>
+        <report_title>Holdings Codes</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Holdings Codes.Evergreen Circulation Modifier.Evergreen Shelving Locatione</heading>
+        <query>SELECT COUNT(l_barcode), l_activeholdingscode FROM ctlocitem_tsv_clean GROUP BY 2 ORDER BY 2</query>
+    </report>
+<!--
+    <report>
+        <name>tlc_load_asset_callnumbertype</name>
+        <report_title>Call Number Types</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Copy Count.Call Number Type.Evergreen Call Number Type.Notes</heading>
+        <query>SELECT COUNT(l_barcode), l_callnumbertype FROM ctlocitem_tsv_clean GROUP BY 2 ORDER BY 2</query>
+        <note>Mappable to generic, LoC and Dewey types in Evergreen.</note>
+    </report>
+-->
+<!-- 
+    <report>
+        <name>tlc_load_asset_callnumberparts</name>
+        <report_title>Call Number Parts</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Copy Count.Call Number Part.Evergreen Sequence.Evergreen Call Number Part.Delimiter</heading>
+        <query>SELECT COUNT(l_barcode) FROM ctlocitem_tsv_clean, 'Prefixes' WHERE l_callnumberprefix IS NOT NULL GROUP BY 1 UNION ALL SELECT 'Class Label', COUNT(l_barcode) FROM ctlocitem_tsv_clean WHERE l_callnumberclass IS NOT NULL GROUP BY 1 UNION ALL SELECT 'Cutter', COUNT(l_barcode) FROM ctlocitem_tsv_clean WHERE l_callnumbercutter IS NOT NULL GROUP BY 1 UNION ALL SELECT 'Year', COUNT(l_barcode) FROM ctlocitem_tsv_clean WHERE l_year IS NOT NULL GROUP BY 1 UNION ALL SELECT 'Volume', COUNT(l_barcode) FROM ctlocitem_tsv_clean WHERE l_volume IS NOT NULL GROUP BY 1</query>
+    </report>
+-->
+    <report>
+        <name>tlc_load_asset_barcodes_with_spaces</name>
+        <report_title>Count of Barcodes with Spaces</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count of Barcodes With Spaces.Transformation</heading>
+        <query>SELECT COUNT(l_itembarcode) FROM ititeminformation_tsv_clean WHERE l_itembarcode ~* ' '</query>
+    </report>
+
+    <report>
+        <name>tlc_load_money_migrating_bills</name>
+        <report_title>Migrating Bills By Bill Type</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Billing Type.Evergreen Bill Type</heading>
+        <query>SELECT COUNT(a.l_chargenumber), b.l_description FROM itpayment_tsv_clean a JOIN itpaymenttype_tsv_clean b ON b.l_paymenttype = a.l_paymenttype WHERE a.l_dueamount::INTEGER - (a.l_waiveamount::INTEGER + a.l_tenderamount::INTEGER) > 0 GROUP BY 2 ORDER BY 2 </query>
+    </report>
+
+    <report>
+        <name>tlc_load_usrs_bygroup</name>
+        <report_title>Patrons by Agency Type</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Permission Group.Evergreen Permission Group</heading>
+        <query>SELECT COUNT(l_agencynumber), l_agencytype FROM itagency_tsv_clean GROUP BY 2 ORDER BY 2</query>
+    </report>
+
+    <report>
+        <name>tlc_load_usrs_byexpiration</name>
+        <report_title>Patrons by Expiration Date</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Year of Expiration.Do Not Migrate?</heading>
+        <query>SELECT COUNT(l_agencynumber), LEFT(l_expirationdate,4) FROM itagency_tsv_clean GROUP BY 2 ORDER BY 2</query>
+    </report>
+
+    <report>
+        <name>tlc_load_usrs_bynever</name>
+        <report_title>Patrons With Claims</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Claim Type.Do Not Migrate</heading>
+        <query>SELECT COUNT(l_agencynumber) FROM itagency_tsv_clean, 'Never Checked Out' WHERE l_itemsclaimednevercheckedout != '0' GROUP BY 1 UNION ALL SELECT COUNT(l_agencynumber), 'Claims Returned' FROM itagency_tsv_clean WHERE l_itemsclaimedreturned != '0' GROUP BY 1</query>
+    </report>
+
+    <report>
+        <name>tlc_load_usrs_byactive</name>
+        <report_title>Patrons by Last Active Date</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Year Last Active.Migrate as Active Flag?</heading>
+        <query>SELECT COUNT(l_agencynumber), LEFT(l_lastactivedate,4) FROM itagency_tsv_clean GROUP BY 2 ORDER BY 2</query>
+        <note>We can set the active flag based on this if desired.</note>
+    </report>
+
+    <report>
+        <name>tlc_load_usrs_blocks</name>
+        <report_title>Patrons by Block Status</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Block Status.Migration Note</heading>
+        <query>SELECT COUNT(l_agencynumber), l_blockstatus FROM itagency_tsv_clean GROUP BY 2 ORDER BY 2</query>
+    </report>
+
+    <report>
+        <name>tlc_load_usrs_gender</name>
+        <report_title>Patrons by Gender</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Gender.Migrate as Stat Cat</heading>
+        <query>SELECT COUNT(l_agencynumber), l_gender FROM itagency_tsv_clean GROUP BY 2 ORDER BY 2</query>
+        <note>Evergreen can load these as statistical categories</note>
+    </report>
+
+    <report>
+        <name>tlc_load_usrs_alternate_ids</name>
+        <report_title>Count of Patrons w Alt Id</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Migration Need</heading>
+        <query>SELECT COUNT(l_agencynumber) FROM itagency_tsv_clean WHERE l_alternateid IS NOT NULL</query>
+    </report>
+
+    <report>
+        <name>tlc_load_active_usr_passwords</name>
+        <report_title>Count of Patrons w Passwords</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count of NULL PINs.Default Password</heading>
+        <query>SELECT COUNT(l_agencynumber) FROM itagency_tsv_clean WHERE l_pin IS NULL</query>
+        <note>If any PINS are blank we will have to choose a method to supply them as Evergreen requires passwords.</note>
+    </report>
+
+    <report>
+        <name>tlc_load_usr_barcodes_wspacess</name>
+        <report_title>Barcodes with Spaces</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count</heading>
+        <query>SELECT COUNT(l_agencynumber) FROM itagency_tsv_clean WHERE l_barcode ~* ' '</query>
+    </report>
+
+    <report>
+        <name>tlc_load_usr_barcode_lengths</name>
+        <report_title>Barcode Lengths by Library</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count of Barcode.Barcode Length.Branch.Transformation Note</heading>
+        <query>SELECT COUNT(l_agencynumber), LENGTH(l_barcode), l_issuingbranch FROM itagency_tsv_clean GROUP BY 2, 3 ORDER BY 3, 2</query>
+    </report>
+
+   <report>
+        <name>tlc_load_usr_notes</name>
+        <report_title>Count of Patron Notes</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Note Type.Action</heading>
+        <query>SELECT COUNT(l_agencynumber), 'Patron Note' FROM itagency_tsv_clean WHERE l_agencycomment IS  NOT NULL UNION ALL SELECT COUNT(l_agencynumber), 'Address Comments' FROM itaddress_tsv_clean WHERE l_addresscomment IS NOT NULL</query>
+    </report>
+    
+    <report>
+        <name>tlc_load_misc</name>
+        <report_title>Miscellaneous Options</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Option.Value.Note</heading>
+        <query>SELECT COUNT(l_agencynumber), 'Create Evergreen Grouped/Family Accounts?' FROM itagency_tsv_clean WHERE l_responsibleagencynumber IS NOT NULL GROUP BY 2 UNION ALL SELECT COUNT(l_itembarcode), 'Lost Items' FROM ititemlocation_tsv_clean WHERE l_outdate IS NOT NULL AND l_status = 'L' GROUP BY 2</query>
+    </report>
+
+    <report>
+        <name>tlc_load_usr_balance</name>
+        <report_title>Count and Sum of Balances</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.SUM in Pennies.Migrate?</heading>
+        <query>SELECT COUNT(l_agencynumber), SUM(l_accountbalance::INTEGER) FROM itagency_tsv_clean WHERE l_accountbalance != '0'</query>
+        <note>If this is being migrated there are a few options of how to do it and each will have different workflows.</note>
+    </report>
+
+    <report>
+        <name>tlc_load_usr_addresses_phones</name>
+        <report_title>Patron Phones</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Count.Phone Type.Phone Type</heading>
+        <query>SELECT COUNT(l_phone1), 'Phone 1' FROM itaddress_tsv_clean WHERE l_phone1 IS NOT NULL GROUP BY 2 UNION ALL SELECT COUNT(l_phone1), 'Phone 2' FROM itaddress_tsv_clean WHERE l_phone2 IS NOT NULL GROUP BY 2</query>
+        <note>These need to be mounted to Evergreen phone fields.</note>
+    </report>
+
+    <report>
+         <name>tlc_load_usr_stat_cats</name>
+        <report_title>Patron Stat Cats and Counts</report_title>
+        <tag>tlc</tag>
+        <iteration>0</iteration>
+        <heading>Patron Count.Stat Cat.Migrate?</heading>
+        <query>SELECT COUNT(b.l_agencynumber), a.l_description FROM itagencyfields_tsv_clean a JOIN itagencydata_tsv_clean b ON b.l_agencyfieldnumber = a.l_agencyfieldnumber GROUP BY 2 ORDER BY 1</query>
+    </report>
+
+<!-- destiny -->
+
+    <report>
+        <name>destiny_load_usr_by_gradelevel</name>
+        <report_title>Patrons by Destiny Grade Level</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Count.Graduation Year</heading>
+        <query>SELECT COUNT(*), grade_level FROM patrons_csv GROUP BY 2 ORDER BY 2</query>
+        <note>Transfer to note or stat cat?</note>
+    </report>
+    
+        <report>
+        <name>destiny_load_usr_by_gender</name>
+        <report_title>Patrons by Destiny Gender</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Count.Gender</heading>
+        <query>SELECT COUNT(*), gender FROM patrons_csv GROUP BY 2 ORDER BY 2</query>
+        <note>Transfer to stat cat?</note>
+    </report>
+    
+        <report>
+        <name>destiny_load_usr_by_patrontype</name>
+        <report_title>Patrons by Destiny Patron Type</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Count.Patron Type.Permission Group</heading>
+        <query>SELECT COUNT(*), patron_type FROM patrons_csv GROUP BY 2 ORDER BY 2</query>
+    </report>
+    
+    <report>
+        <name>destiny_load_usr_by_status</name>
+        <report_title>Patrons by Destiny Status</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Count.Status</heading>
+        <query>SELECT COUNT(*), status FROM patrons_csv GROUP BY 2 ORDER BY 2</query>
+    </report>
+    
+    <report>
+        <name>destiny_load_usr_by_municipality</name>
+        <report_title>Patrons by Municipality</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Count.Municipality</heading>
+        <query>SELECT COUNT(*), municipality FROM patrons_csv GROUP BY 2 ORDER BY 2</query>
+        <note>State cat?</note>
+    </report>
+    
+    <report>
+        <name>destiny_load_usr_notes</name>
+        <report_title>Types of and Counts of Notes</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Type of Note.Count</heading>
+        <query>SELECT 'General Note', COUNT(*) FROM patrons_csv WHERE note_general IS NOT NULL and note_general != '' UNION ALL SELECT 'Important Note', COUNT(*) FROM patrons_csv WHERE note_important IS NOT NULL and note_important != '' </query>
+        <note>Messsage / alert / note?</note>
+    </report>
+    
+    <report>
+        <name>destiny_load_usr_userdefined5</name>
+        <report_title>User Defined Field 5</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Count.Values</heading>
+        <query>SELECT COUNT(*), user_defined_5 FROM patrons_csv GROUP BY 2 ORDER BY 2</query>
+        <note>Retain somewhere?</note>
+    </report>
+    
+    <report>
+        <name>destiny_load_usrs_pswdconfigured</name>
+        <report_title>Patrons by Password Configured</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Count.Password Configured</heading>
+        <query>SELECT COUNT(*), password_configured FROM patrons_csv GROUP BY 2 ORDER BY 2</query>
+        <note>Need how they want passwords set since we don't have them to migrate and do they want these that are configured with some special note?</note>
+    </report>
+
+    <report>
+        <name>destiny_load_usrs_phonefields</name>
+        <report_title>Phone Fields</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Phone Field.Count.Evergreen Phone Field</heading>
+        <query>SELECT 'Primary Phone 1', COUNT(*) FROM patrons_csv WHERE primary_phone_1 IS NOT NULL AND primary_phone_1 != '' UNION ALL SELECT 'Primary Phone 2', COUNT(*) FROM patrons_csv WHERE primary_phone_2 IS NOT NULL AND primary_phone_2 != '' UNION ALL SELECT 'Secondary Phone 1', COUNT(*) FROM patrons_csv WHERE secondary_phone_1 IS NOT NULL AND secondary_phone_1 != '' UNION ALL SELECT 'Secondary Phone 2', COUNT(*) FROM patrons_csv WHERE secondary_phone_2 IS NOT NULL AND secondary_phone_2 != '' </query>
+    </report>
+    
+    <report>
+        <name>destiny_load_asset_categories</name>
+        <report_title>Count of Categories</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Count.Category.Circ Mod?</heading>
+        <query>SELECT COUNT(*), category FROM copies_csv GROUP BY 2 ORDER BY 2</query>
+    </report>
+    
+    <report>
+        <name>destiny_load_asset_notes</name>
+        <report_title>Copies by Note Types</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Note Type.Count</heading>
+        <query>SELECT 'General Note', COUNT(*) FROM copies_csv WHERE note_general IS NOT NULL and note_general != '' UNION ALL SELECT 'Important Note', COUNT(*) FROM copies_csv WHERE note_important IS NOT NULL and note_important != ''</query>
+        <note>Retain?</note>
+    </report>
+    
+        <report>
+        <name>destiny_load_asset_sublocation</name>
+        <report_title>Copies by Sub Location</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Count.Sub Location.Shelving Location?</heading>
+        <query>SELECT COUNT(*), sublocation FROM copies_csv GROUP BY 2 ORDER BY 2</query>
+    </report>
+    
+    <report>
+        <name>destiny_load_asset_vendor</name>
+        <report_title>Copies by Vendor</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Count.Vendor</heading>
+        <query>SELECT COUNT(*), vendor FROM copies_csv GROUP BY 2 ORDER BY 2</query>
+        <note>Retain?</note>
+    </report>
+    
+    <report>
+        <name>destiny_load_asset_descriptions</name>
+        <report_title>Copies with Description Fields</report_title>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <heading>Description Field.Count</heading>
+        <query>SELECT 'Description Field 1', COUNT(*) FROM copies_csv WHERE description_1 IS NOT NULL and description_1 != '' UNION ALL SELECT 'Description Field 2', COUNT(*) FROM copies_csv WHERE description_2 IS NOT NULL and description_2 != '' UNION ALL SELECT 'Description Field 3', COUNT(*) FROM copies_csv WHERE description_3 IS NOT NULL and description_3 != ''</query>
+        <note>Need report?  Retain?</note>
+    </report>
+    
+    <report>
+        <name>destiny_load_fines_byreason</name>
+        <tag>destiny</tag>
+        <iteration>0</iteration>
+        <report_title>Fines by Reason</report_title>
+        <heading>Count.Reason</heading>
+        <query>SELECT COUNT(*), reason FROM fines_csv GROUP BY 2 ORDER BY 2</query>
+    </report>
+
+<!-- apollo -->
+
+
+    <report>
+        <name>circ_bystatus</name>
+        <report_title>Circulations by Status</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Count.Status.Type</heading>
+        <query>SELECT COUNT(id), l_status, l_type FROM action_circulation_legacy GROUP BY 2, 3</query>
+        <note>Circulations will only not be migrated if they can't be attached to a migrated patron and holding.</note>
+    </report>
+
+    <report>
+        <name>hold_bystatus</name>
+        <report_title>Holds by Status</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Count.Status</heading>
+        <query> SELECT COUNT(id), l_status FROM action_hold_request_legacy GROUP BY 2</query>
+        <note>Only unfilled holds are being migrated.</note>
+    </report>
+
+    <report>
+        <name>asset_pending_bibs</name>
+        <report_title>Pending Records</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Count.Year of Last Edit.Count of Copies Attached</heading>
+        <query>SELECT COUNT(bre.id), CASE WHEN LENGTH(bre.l_edited) > 1 THEN EXTRACT(YEAR FROM bre.l_edited::TIMESTAMP) ELSE '1900' END, COUNT(ac.id) FROM biblio_record_entry_legacy bre LEFT JOIN asset_copy_legacy ac ON ac.l_biblio = bre.l_id WHERE bre.l_status = 'pending' GROUP BY 2 ORDER BY 2
+</query>
+    </report>
+
+    <report>
+        <name>asset_copies_by_status</name>
+        <report_title>Copies by Status</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Count.Status</heading>
+        <query>SELECT COUNT(id), l_status FROM asset_copy_legacy GROUP BY 2 ORDER BY 2</query>
+        <note>Deleted copies with a delete date were not exported additionally those with the deleted status won't get loaded.</note>
+    </report>
+
+    <report>
+        <name>asset_pending_copies</name>
+        <report_title>Pending Copies by Last Edit</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Count.Last Edited</heading>
+        <query>SELECT COUNT(id), CASE WHEN LENGTH(l_edited) > 1 THEN EXTRACT(YEAR FROM l_edited::TIMESTAMP) ELSE '1900' END FROM asset_copy_legacy WHERE l_status = 'pending' GROUP BY 2 ORDER BY 2</query>
+    </report>
+
+    <report>
+        <name>assets_by_memberships</name>
+        <report_title>Copies by Memberships</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Count.Membership Number.Membership Name</heading>
+        <query>SELECT COUNT(ac.id), acl.l_membership_number, acl.l_membership_name FROM asset_copy_legacy ac JOIN asset_copy_location_legacy acl ON acl.l_membership_name = ac.l_memberships GROUP BY 2,3 ORDER BY 2
+</query>
+    </report>
+
+   <report>
+        <name>money_bills</name>
+        <report_title>Bills</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Count.Status</heading>
+        <query>SELECT COUNT(id), l_status FROM money_billing_legacy GROUP BY 2 ORDER BY 2</query>
+        <note>Unless there is a good reason to do so forgiven and paid bills will not be migrated.</note>
+    </report>
+
+   <report>
+        <name>actor_groups</name>
+        <report_title>Patron Membership Groups</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Membership List Name.Membership List ID.Membership Number.Membership Name.Membership Length in Monthst</heading>
+        <query>SELECT l_membership_list_name, l_membership_list_id, l_membership_number, l_membership_name, l_membership_length_months FROM actor_usr_legacy_groups_tsv ORDER BY 1, 3</query>
+        <note>Age looks like a good target for a stat cat and / or juvenile setting while the patron type can map to profiles.</note>
+    </report>
+
+    <report>
+        <name>actor_by_groups</name>
+        <report_title>Patrons by Membership Groups</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Count.Membership List Name.Membership Number</heading>
+        <query>SELECT COUNT(*), l_membership_list_name, l_membership_number FROM (SELECT id, UNNEST(STRING_TO_ARRAY(l_memberships,'|')) AS m FROM actor_usr_legacy ) x JOIN actor_usr_legacy_groups_tsv t ON t.l_membership_name = x.m GROUP BY 2, 3 ORDER BY 2, 3</query>
+    </report>
+
+    <report>
+        <name>actor_addresses_nulls</name>
+        <report_title>Patron Addresses</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Address Field.Nulls</heading>
+        <query>SELECT 'Street Address', COUNT(id) FROM actor_usr_address_legacy WHERE l_lines IS NULL UNION ALL SELECT 'City', COUNT(id) FROM actor_usr_address_legacy UNION ALL SELECT 'State', COUNT(id) FROM actor_usr_address_legacy WHERE l_country_division IS NULL UNION ALL SELECT 'Postal Code', COUNT(id) FROM actor_usr_address_legacy WHERE l_postal_code IS NULL </query>
+        <note>If any of these fields are null then we need defaults to fill in, note the extract had no city data.</note>
+    </report>
+
+    <report>
+        <name>actor_phones</name>
+        <report_title>Patron Phones</report_title>
+        <tag>apollo</tag>
+        <iteration>0</iteration>
+        <heading>Count.Type</heading>
+        <query>SELECT COUNT(*), l_type FROM actor_usr_phones_tsv GROUP BY 2 ORDER BY 2</query>
+        <note>These need to be mapped to Evergreen phone types.</note>
+    </report>
+
+    <report>
+        <name>hz_borrowersbybtypes</name>
+        <report_title>Borrowers by Borrower Types</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Count.Borrower Type</heading>
+        <query>SELECT COUNT(id), l_borrower_btype FROM actor_usr_legacy GROUP BY 2 ORDER BY 2;</query>
+    </report>
+
+    <report>
+        <name>hz_borrowerpinsamples</name>
+        <report_title>Borrower PINs Samples</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Sample PINs</heading>
+        <query>SELECT l_borrower_pin FROM actor_usr_legacy WHERE LENGTH(l_borrower_pin) > 1 LIMIT 20;</query>
+        <note>Only 16 PINS defined.</note>
+    </report>
+    
+    <report>
+        <name>hz_borrowernotesample</name>
+        <report_title>Borrower Note Field Samples</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Count</heading>
+        <query>SELECT l_borrower_borrower_note FROM actor_usr_legacy WHERE LENGTH(l_borrower_borrower_note) > 1 LIMIT 20;</query>
+        <note>19,473</note>
+    </report>
+
+    <report>
+        <name>hz_borrowernotesample2</name>
+        <report_title>Borrower Note Field 2 Samples</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Count</heading>
+        <query>SELECT l_borrower_note2 FROM actor_usr_legacy WHERE LENGTH(l_borrower_note2) > 1 LIMIT 20;</query>
+        <note>78</note>
+    </report>
+
+    <report>
+        <name>hz_borrowernotesample3</name>
+        <report_title>Borrower Note Field 3 Samples</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Count</heading>
+        <query>SELECT l_borrower_note3 FROM actor_usr_legacy WHERE LENGTH(l_borrower_note3) > 1 LIMIT 20;</query>
+        <note>Only 6.</note>
+    </report>
+
+    <report>
+        <name>hz_phones</name>
+        <report_title>Borrower Phones</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Count.Borrower Phone Type</heading>
+        <query>
+        SELECT COUNT(*), b 
+        FROM (SELECT l_borrower_phone_1_phone_type AS b FROM actor_usr_legacy
+        UNION ALL SELECT l_borrower_phone_2_phone_type AS b FROM actor_usr_legacy
+        UNION ALL SELECT l_borrower_phone_3_phone_type AS b FROM actor_usr_legacy
+        UNION ALL SELECT l_borrower_phone_4_phone_type AS b FROM actor_usr_legacy) x 
+        GROUP BY 2 ORDER BY 2
+        </query>
+        <note>Ordinal phones will have to be combined.</note>
+    </report>
+
+    <report>
+        <name>hz_bstats</name>
+        <report_title>Borrower B-Stats</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Count.BStat</heading>
+        <query>SELECT COUNT(*), b 
+        FROM (SELECT l_borrower_bstat_1_bstat AS b FROM actor_usr_legacy
+        UNION ALL
+        SELECT l_borrower_bstat_2_bstat AS b FROM actor_usr_legacy
+        UNION ALL
+        SELECT l_borrower_bstat_3_bstat AS b FROM actor_usr_legacy) x
+        GROUP BY 2 ORDER BY 1;
+        </query>
+    </report>
+    
+    <report>
+        <name>hz_copybycollection</name>
+        <report_title>Copies by Collection</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Count.Collection</heading>
+        <query>SELECT COUNT(id), l_collection FROM asset_copy_legacy GROUP BY 2 ORDER BY 2;</query>
+    </report>
+    
+    <report>
+        <name>hz_copyfieldexamples</name>
+        <report_title>Sample Copy Field Values</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Field</heading>
+        <query>SELECT l_copy FROM asset_copy_legacy WHERE LENGTH(l_copy) > 1 LIMIT 30;</query>
+    </report>
+
+    <report>
+        <name>hz_itemsbyitype</name>
+        <report_title>Items by IType</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Count.Item Type (itype)</heading>
+        <query>SELECT COUNT(id), l_itype FROM asset_copy_legacy GROUP BY 2 ORDER BY 2;</query>
+    </report>
+    
+    <report>
+        <name>hz_volfieldexamples</name>
+        <report_title>Sample Volume Field Values</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Field</heading>
+        <query>SELECT l_volume FROM asset_copy_legacy WHERE LENGTH(l_volume) > 1 LIMIT 30;</query>
+        <note></note>
+    </report>
+    
+     <report>
+        <name>hz_iteminhouseuses</name>
+        <report_title>Item In House Uses</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Count.Number of Uses</heading>
+        <query>SELECT COUNT(id), l_n_inhouse_uses FROM asset_copy_legacy GROUP BY 2 ORDER BY 2;</query>
+    </report>
+    
+    <report>
+        <name>hz_internalnotesample</name>
+        <report_title>Internal Item Notes</report_title>
+        <tag>horizon</tag>
+        <iteration>0</iteration>
+        <heading>Sample Note</heading>
+        <query>SELECT l_internal_note FROM asset_copy_legacy WHERE LENGTH(l_internal_note) > 1 LIMIT 30;</query>
+    </report>
+    
+<!-- resource mate -->
+
+    <report>
+        <name>rm_load_circ_count</name>
+        <tag>rm</tag>
+        <iteration>0</iteration>
+        <report_title>Circs by Status</report_title>
+        <heading>Count of Circs.Status</heading>
+        <query>SELECT COUNT(id), l_is_checked_out FROM asset_copy_legacy GROUP BY 2</query>
+    </report>
+
+   <report>
+        <name>rm_load_asset_by_resource_type</name>
+        <report_title>Resource Type</report_title>
+        <tag>rm</tag>
+        <iteration>0</iteration>
+        <heading>Count.Resource Type</heading>
+        <query>SELECT COUNT(*), l_resource_type FROM asset_copy_legacy GROUP BY 2 ORDER BY 2</query>
+    </report>
+
+   <report>
+        <name>rm_load_asset_by_location</name>
+        <report_title>Copies by Location</report_title>
+        <tag>rm</tag>
+        <iteration>0</iteration>
+        <heading>Count.Location</heading>
+        <query>SELECT COUNT(*), l_location FROM asset_copy_legacy GROUP BY 2 ORDER BY 2</query>
+    </report>
+
+    <report>
+        <name>rm_load_asset_by_category</name>
+        <report_title>Copies by Category</report_title>
+        <tag>rm</tag>
+        <iteration>0</iteration>
+        <heading>Count.Category</heading>
+        <query>SELECT COUNT(*), l_category FROM asset_copy_legacy GROUP BY 2 ORDER BY 2</query>
+    </report>
+   
+    <report>
+        <name>rm_load_asset_by_status</name>
+        <report_title>Copies by Status</report_title>
+        <tag>rm</tag>
+        <iteration>0</iteration>
+        <heading>Count.Status</heading>
+        <query>SELECT COUNT(*), l_status FROM asset_copy_legacy GROUP BY 2 ORDER BY 2</query>
+    </report>
+
+    <report>
+        <name>rm_actor_groups</name>
+        <report_title>Patrons by User Groups</report_title>
+        <tag>rm</tag>
+        <iteration>0</iteration>
+        <heading>Count.Group</heading>
+        <query>SELECT COUNT(id), l_user_group FROM actor_usr_legacy GROUP BY 2 ORDER BY 2;
+        </query>
+    </report>
+
+    <report>
+        <name>rm_actor_access</name>
+        <report_title>Patrons by Access Field</report_title>
+        <tag>rm</tag>
+        <iteration>0</iteration>
+        <heading>Count.Access</heading>
+        <query>SELECT COUNT(id), l_access_if_applicable FROM actor_usr_legacy GROUP BY 2 ORDER BY 2;
+        </query>
+    </report>
+    <report>
+        <name>rm_actor_comments</name>
+        <report_title>Patron Comments</report_title>
+        <tag>rm</tag>
+        <iteration>0</iteration>
+        <heading>Count.Sample</heading>
+        <query>SELECT COUNT(id), 'All Comments' FROM actor_usr_legacy WHERE LENGTH(l_comments) > 1
+            UNION ALL SELECT NULL, l_comments FROM  actor_usr_legacy WHERE LENGTH(l_comments) > 1 LIMIT 10
+        </query>
+    </report>
+
+    <report>
+        <name>rm_actor_circulation_note</name>
+        <report_title>Patron Circ Notes</report_title>
+        <tag>rm</tag>
+        <iteration>0</iteration>
+        <heading>Count.Sample</heading>
+        <query>SELECT COUNT(id), 'All Notes' FROM actor_usr_legacy WHERE LENGTH(l_circulation_note) > 1
+            UNION ALL SELECT NULL, l_circulation_note FROM  actor_usr_legacy WHERE LENGTH(l_circulation_note) > 1 LIMIT 10
+        </query>
+    </report>
+
+
+</reports_file>