diff options
author | ivan <ivan> | 2006-09-16 20:07:46 +0000 |
---|---|---|
committer | ivan <ivan> | 2006-09-16 20:07:46 +0000 |
commit | b143ebbf9839934aebfdda61d988d55df6e34dc7 (patch) | |
tree | b36e5e80221e4823f207377b58d88cc40add1c71 /bin | |
parent | b9659e5372a344fbc027720939625de1fd99645d (diff) |
bulk fake customer insert
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/customer-faker | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/bin/customer-faker b/bin/customer-faker new file mode 100755 index 000000000..86c8f7ce0 --- /dev/null +++ b/bin/customer-faker @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +use strict; +use Data::Faker; +use FS::UID qw(adminsuidsetup); +use FS::cust_main; + +my $agentnum = 1; +my $refnum = 1; + +my $user = shift or die &usage; +my $num = shift or die &usage; +adminsuidsetup($user); + +my $onum = $num; +my $start = time; + +until ( $num-- <= 0 ) { + + my $faker = new Data::Faker; + + my $cust_main = new FS::cust_main { + 'agentnum' => $agentnum, + 'refnum' => $refnum, + 'first' => $faker->first_name, + 'last' => $faker->last_name, + 'company' => ( $num % 2 ? $faker->company. ', '. $faker->company_suffix : '' ), #half with companies.. + 'address1' => $faker->street_address, + 'city' => 'Tofutown', #missing, so everyone is from tofutown# $faker->city, + 'state' => $faker->us_state_abbr, + 'zip' => $faker->us_zip_code, + 'country' => 'US', + 'daytime' => $faker->phone_number, + 'night' => $faker->phone_number, + #forget it, these can have extensions# 'fax' => ( $num % 2 ? $faker->phone_number : '' ), #ditto + #bah, forget shipping addresses + 'payby' => 'BILL', + 'payip' => $faker->ip_address, + }; + + # could insert invoicing_list and other stuff too.. hell, could insert + # packages, services, more + # but i just wanted 10k customers to test the pager and this was good enough + + my $error = $cust_main->insert; + die $error if $error; + +} + +my $end = time; + +my $sec = $end-$start; +my $persec = $onum / $sec; +print "$onum customers inserted in $sec seconds ($persec customers/sec)\n"; + +#--- + +sub usage { + die "Usage:\n\n customer-faker user num_fakes\n"; +} |