delete_err => 0
);
+# map of district code to home org unit id.
+my %home_ou_map = (
+ 405 => 1492,
+ 415 => 1520,
+ 409 => 1527
+);
+
# pre-prepared sql query statement handles;
my $create_user_sth;
my $create_addr_sth;
my $district_code; # 3-char school district code
my $default_pass;
my $commit_mode = 'rollback'; # single xact, then rollback (for testing)
-my $assume_new = 0;
my $is_classroom = 0;
my $purge_all = 0;
my $out_dir = '.';
'home-ou=s' => \$home_ou,
'district-code=s' => \$district_code,
'commit-mode=s' => \$commit_mode,
- 'assume-new' => \$assume_new,
'purge-all' => \$purge_all,
'default-pass=s' => \$default_pass,
'classroom' => \$is_classroom,
Processes a patron import CSV file. Student accounts may be created,
updated, or deleted.
-$0 --log-stdout --home-ou 1492 --district-code 405 --commit-mode each \
+$0 --log-stdout --district-code 405 --commit-mode each \
--db-host testing-db01 <csv-file>
Options:
- --home-ou
- Org unit ID of the home library used for all patrons loaded
- in the current file.
-
--district-code
3-character school district code.
+ --home-ou
+ Org unit ID of the home library used for all patrons loaded
+ in the current file. NOTE: Only use this parameter if the
+ home org unit for a batch does not match the default org
+ unit for the selected district code.
+
--default-pass
If set, use this password instead of the last 4 of the student ID.
for production deployments to ensure that all patrons
that insert without failure are added to the DB.
- --assume-new
- Assume all users in the CSV file are new users. No checks will
- be made to see if the user already exists in the DB.
-
--purge-all
Ignore any commands in the CSV file and purge (permanently delete)
every user represented in the file. This is useful for testing.
sub verify_options {
help() if $help; # exits
- die "--home-ou required\n" unless $home_ou;
die "--district-code required\n" unless $district_code;
die "CSV file required\n" unless $csv_file = $ARGV[0];
-
die "Valid --commit-mode values are 'batch', 'rollback', and 'each'\n"
unless $commit_mode =~ /^(batch|rollback|each)$/;
+ $home_ou = $home_ou_map{$district_code} unless $home_ou;
+
# Kent students may be as old as 21.
$expire_age = 21 if $district_code eq '415';
# per-row actions (create, update, delete) in the CSV file to clarify
# which patrons are new.
sub find_new_patrons {
- return if $assume_new or $purge_all; # no lookup required.
+ return if $purge_all; # no lookup required.
my @all_barcodes;
return unless translate_patron_data($phash);
$summary_stats{trans}++;
- if ($assume_new or $new_barcodes{$phash->{barcode}}) {
+ if ($new_barcodes{$phash->{barcode}}) {
create_patron($phash);
} else {
update_patron($phash);