JBAS-1998 College cards import tweaks
authorBill Erickson <berickxx@gmail.com>
Thu, 12 Apr 2018 16:53:50 +0000 (09:53 -0700)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
* 4-year expire
* sftp file checks updates

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl
KCLS/utility-scripts/import_students/sftp-client-agent.sh

index c6e1441..3a4590a 100755 (executable)
@@ -85,6 +85,7 @@ my $default_pass;
 my $commit_mode     = 'rollback'; # single xact, then rollback (for testing)
 my $is_teacher      = 0;
 my $is_classroom    = 0;
+my $is_college      = 0;
 my $purge_all       = 0;
 my $force_new       = 0;
 my $out_dir         = '.';
@@ -106,6 +107,7 @@ GetOptions(
     'default-pass=s'  => \$default_pass,
     'teacher'         => \$is_teacher,
     'classroom'       => \$is_classroom,
+    'college'         => \$is_college,
     'log-stdout'      => \$log_stdout,
     'out-dir=s'       => \$out_dir,
     'db-user=s'       => \$db_user,
@@ -371,6 +373,13 @@ sub set_expire_date {
         return; 
     }
 
+    if ($is_college) {
+        # college cards expire after 4 years.
+        $now_date->set_year($now_year + 4);
+        $phash->{expire_date} = $now_date;
+        return; 
+    }
+
     my ($year, $mon, $day) = ($phash->{dob} =~ /(\d{4})-(\d{2})-(\d{2})/);
     my $expire_year = $now_year + ($expire_age - ($now_year - $year));
 
index 2f71b3b..a135dfb 100755 (executable)
@@ -42,10 +42,15 @@ DISTRICT_CODES=(
     414 # Lake Washington
     415 # Kent
     417 # Northshore
+);
+
+# College students are processed differently
+COLLEGE_CODES=(
     "lwt" # Lake Washington Institute of Technology
 );
 
 # Hard-code the districts eligible for automatic teacher account processing.
+# College teacher accounts are processed the same as school teacher accounts.
 TEACHER_DISTRICTS=(
     402 # Vashon
     403 # Renton
@@ -162,16 +167,22 @@ for code in "${DISTRICT_CODES[@]}"; do
         for FILE in $($SSH "$COMMAND -l"); do
             LOCAL_FILE=$(basename $FILE)
             TEACHER_FLAG=""
+            COLLEGE_FLAG=""
 
             announce "Inspecting file $FILE"
 
             # File format examples:
             # 415.2016-03-18.csv
             # 415.teacher.2016-03-18.csv
-            if [[ $LOCAL_FILE =~ ^[0-9]{3}.[0-9]{4}-[0-9]{2}-[0-9]{2}.csv$ ]]; then
+            if [[ $LOCAL_FILE =~ ^[0-9a-z]{3}.[0-9]{4}-[0-9]{2}-[0-9]{2}.csv$ ]]; then
                 announce "Found a student file."
+
+                if [[ " ${COLLEGE_CODES[@]} " =~ " $code " ]]; then
+                    announce "Processing a college student file"
+                    COLLEGE_FLAG="--college"
+                fi
             else
-                if [[ $LOCAL_FILE =~ ^[0-9]{3}.teacher.[0-9]{4}-[0-9]{2}-[0-9]{2}.csv$ ]]; then
+                if [[ $LOCAL_FILE =~ ^[0-9a-z]{3}.teacher.[0-9]{4}-[0-9]{2}-[0-9]{2}.csv$ ]]; then
                     announce "Found a teacher file."
 
                     if [[ " ${TEACHER_DISTRICTS[@]} " =~ " $code " ]]; then