my $root_org = 1; # KCLS org unit for penalty application
my $expire_age = 21;
my $purge_count = 0; # useful for local logging
+my $max_new_patrons = 500; # Max number of automatically generated new patrons
my $db_handle;
my %new_barcodes;
my @failures; # one row per student account that failed for any reason
my $is_teacher = 0;
my $is_classroom = 0;
my $purge_all = 0;
+my $force_new = 0;
my $out_dir = '.';
my $log_stdout = 0; # copy logs to stdout
my $help = 0; # show help message if true
'district-code=s' => \$district_code,
'commit-mode=s' => \$commit_mode,
'purge-all' => \$purge_all,
+ 'force-new' => \$force_new,
'default-pass=s' => \$default_pass,
'teacher' => \$is_teacher,
'classroom' => \$is_classroom,
every user represented in the file. This is useful for testing.
The user will be prompted to continue. USE WITH CAUTION.
+ --force-new
+ Force the creation of new accounts when the number of new accounts
+ exceeds the "too many new accounts" warning threshold.
+
--out-dir
Output directory for status files. Defaults to current working
directory.
my $new_barcodes = $db_handle->selectall_arrayref($SQL);
- announce('INFO', "New barcodes query returned ".
- scalar(@$new_barcodes) ." new barcodes");
+ my $new_count = scalar(@$new_barcodes);
+ announce('INFO', "New barcodes query returned $new_count new barcodes");
+
+ if ($new_count > $max_new_patrons && !$force_new) {
+ announce('WARNING', "Number of new accounts [$new_count] exceeds ".
+ "warning threshold [$max_new_patrons]. Exiting import. ".
+ "Use --force-new to override", 1);
+ }
# hash-ify for faster lookup when processing each patron
%new_barcodes = map {$_->[0] => 1} @$new_barcodes;