From: Bill Erickson Date: Fri, 10 Feb 2012 20:28:59 +0000 (-0500) Subject: Tweaks to sample user gen script X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=763cf0cd9faca15ea75bdd6a537660ebaeb77a9a;p=working%2FEvergreen.git Tweaks to sample user gen script Updated to generate staff users. Parts of it are hard-coded. It's just here for reference. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/tests/datasets/users_scratch/gen_patron_users.pl b/Open-ILS/tests/datasets/users_scratch/gen_patron_users.pl index a284584d1c..b5bd5caddc 100755 --- a/Open-ILS/tests/datasets/users_scratch/gen_patron_users.pl +++ b/Open-ILS/tests/datasets/users_scratch/gen_patron_users.pl @@ -16,13 +16,26 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -my $n = 100; # number of patrons to generate +#my $n = 100; # number of patrons to generate +my $n = 134; # staff ############################################### # examples -my @profiles = ( 2 ); +my @profiles = ( 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15 ); my @ident_types = ( 1, 3 ); my @home_ou = ( 4, 5, 6, 7, 8, 9 ); + +my @prof_org; +for my $prof (@profiles) { + for my $org (@home_ou) { + # 2 of each + push(@prof_org, [$prof, $org]); + push(@prof_org, [$prof, $org]); + } +} +# add a couple of global admins +push(@prof_org, [13, 4]); +push(@prof_org, [13, 6]); ############################################### my @last_names = (); @@ -34,6 +47,8 @@ my @nouns = (); my @adjectives = (); my @zips = (); my %zip = {}; +my $is_staff = $ARGV[6]; + sub gen_sql { my ($profile, $ident_type, $usrname, $home_ou, $family_name, $passwd, $first_given_name, $second_given_name, $expire_date, $dob, $suffix) = (shift, shift, shift, shift, shift, shift, shift, shift, shift, shift,shift); @@ -62,8 +77,19 @@ UPDATE actor.usr SET credit_forward_balance = '0', mailing_address = CURRVAL('actor.usr_address_id_seq') WHERE id=CURRVAL('actor.usr_id_seq'); +SQL + + if ($is_staff) { + print < 50 ? $barcode : lc($nouns[ int(rand( scalar(@nouns) )) ] . $usrname_suffix); -# if (! defined $seen_usrname{$usrname} ) { -# $seen_usrname{$usrname} = 1; -# last; -# } -# } - my $fname = $gender > 50 ? $male_names[ int(rand( scalar(@male_names) )) ] : $female_names[ int(rand( scalar(@female_names) )) ]; @@ -133,11 +149,29 @@ foreach my $x ( 1..$n) { my $lname = $last_names[ int(rand( scalar(@last_names) )) ]; + my $usrname = $barcode; + $usrname = lc(substr($fname, 0, 1) . $lname) if $is_staff; + $seen_usrname{$usrname} = 1; + +# my $usrname; +# while(true) { +# my $usrname_suffix = int(rand(1000)); +# $usrname = rand(100) > 50 ? $barcode : lc($nouns[ int(rand( scalar(@nouns) )) ] . $usrname_suffix); +# if (! defined $seen_usrname{$usrname} ) { +# $seen_usrname{$usrname} = 1; +# last; +# } +# } + + + my $prof_org = pop(@prof_org); gen_sql( - $profiles[ int(rand( scalar(@profiles) )) ], # profile + #$profiles[ int(rand( scalar(@profiles) )) ], # profile + $$prof_org[0], $ident_types[ int(rand( scalar(@ident_types) )) ], # ident_type - $barcode, # usrname - $home_ou[ int(rand( scalar(@home_ou) )) ], # home_ou + $usrname, + #$home_ou[ int(rand( scalar(@home_ou) )) ], # home_ou + $$prof_org[1], $lname, # family_name; lc($fname . substr($lname, 0, 1) . '1234'), # passwd $fname, # first_given_name @@ -157,4 +191,5 @@ foreach my $x ( 1..$n) { $barcode, # barcode ); } + print "COMMIT;\n";