From 91ffbe623f9d23407ff622de121f7c38aca23be8 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 10 Aug 2007 09:20:36 +0000 Subject: [PATCH] =?utf8?q?perltidy=20dr=C3=BCbergejagt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.brehm-online.com/svn/cookbook/trunk@19 191103c4-1d37-0410-b3e5-d8c2315c0aac --- lib/CookBook/Db/Units.pm | 18 +++++------ sbin/initial_import.pl | 70 ++++++++++++++++++++-------------------- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/lib/CookBook/Db/Units.pm b/lib/CookBook/Db/Units.pm index aba7696..d91cd8b 100644 --- a/lib/CookBook/Db/Units.pm +++ b/lib/CookBook/Db/Units.pm @@ -39,21 +39,19 @@ __PACKAGE__->add_columns( 'is_auto_increment' => 1, 'extras' => { 'unsigned' => 1 }, }, - "unit_name" => { 'data_type' => "VARCHAR", 'default_value' => "", 'is_nullable' => 0, 'size' => 50 }, - "unit_name_abbrev" => { 'data_type' => "VARCHAR", 'default_value' => undef, 'is_nullable' => 1, 'size' => 20 }, - "unit_plural" => { 'data_type' => "VARCHAR", 'default_value' => "", 'is_nullable' => 0, 'size' => 50 }, - "unit_plural_abbrev" => { 'data_type' => "VARCHAR", 'default_value' => undef, 'is_nullable' => 1, 'size' => 20 }, - "unit_type_id" => { 'data_type' => "INT", 'default_value' => '0', 'is_nullable' => 0, 'size' => 10, 'extras' => { 'unsigned' => 1 } }, - "date_created" => { 'data_type' => "DATETIME", 'default_value' => "", 'is_nullable' => 0, 'size' => 19 }, - "date_changed" => { 'data_type' => "DATETIME", 'default_value' => "", 'is_nullable' => 0, 'size' => 19 }, + "unit_name" => { 'data_type' => "VARCHAR", 'default_value' => "", 'is_nullable' => 0, 'size' => 50 }, + "unit_name_abbrev" => { 'data_type' => "VARCHAR", 'default_value' => undef, 'is_nullable' => 1, 'size' => 20 }, + "unit_plural" => { 'data_type' => "VARCHAR", 'default_value' => "", 'is_nullable' => 0, 'size' => 50 }, + "unit_plural_abbrev" => { 'data_type' => "VARCHAR", 'default_value' => undef, 'is_nullable' => 1, 'size' => 20 }, + "unit_type_id" => { 'data_type' => "INT", 'default_value' => '0', 'is_nullable' => 0, 'size' => 10, 'extras' => { 'unsigned' => 1 } }, + "date_created" => { 'data_type' => "DATETIME", 'default_value' => "", 'is_nullable' => 0, 'size' => 19 }, + "date_changed" => { 'data_type' => "DATETIME", 'default_value' => "", 'is_nullable' => 0, 'size' => 19 }, ); __PACKAGE__->set_primary_key("unit_id"); __PACKAGE__->add_unique_constraint( "unit_name", ["unit_name"] ); - -__PACKAGE__->belongs_to( 'unit_type' => 'CookBook::Db::UnitTypes', 'unit_type_id', ); - +__PACKAGE__->belongs_to( 'unit_type' => 'CookBook::Db::UnitTypes', 'unit_type_id', ); #---------------------------------------------------------------------------------------- diff --git a/sbin/initial_import.pl b/sbin/initial_import.pl index 4c8cc65..92a83f3 100755 --- a/sbin/initial_import.pl +++ b/sbin/initial_import.pl @@ -59,25 +59,25 @@ my %create_method = ( ); my @import_tables = qw( - authors - yield_types - units - ingredients - ingredient_groups - recipes - recipe_authors - recipe_ingredients + authors + yield_types + units + ingredients + ingredient_groups + recipes + recipe_authors + recipe_ingredients ); my %import_method = ( - 'authors' => \&import_author_table, - 'yield_types' => \&import_yield_types_table, - 'units' => \&import_units_table, - 'ingredients' => \&import_ingredients_table, - 'ingredient_groups' => \&import_ingredient_groups_table, - 'recipes' => \&import_recipes_table, - 'recipe_authors' => \&import_recipe_authors_table, - 'recipe_ingredients' => \&import_recipe_ingredients_table, + 'authors' => \&import_author_table, + 'yield_types' => \&import_yield_types_table, + 'units' => \&import_units_table, + 'ingredients' => \&import_ingredients_table, + 'ingredient_groups' => \&import_ingredient_groups_table, + 'recipes' => \&import_recipes_table, + 'recipe_authors' => \&import_recipe_authors_table, + 'recipe_ingredients' => \&import_recipe_ingredients_table, ); my $admin_data = { @@ -451,7 +451,7 @@ sub import_data { return undef; } print ok() . "\n"; - } ## end for my $table (@target_tables) + } ## end for my $table (@import_tables) print "\n"; return 1; @@ -577,7 +577,7 @@ END_SQL return undef unless $target_dbh->do($sql); return 1; -} ## end sub create_recipe_authors_table +} ## end sub create_ingredients_table #------------------------------------------------------------- @@ -622,11 +622,11 @@ END_SQL $map_ingredient_id{ $ingr->{'id'} } = $target_dbh->{'mysql_insertid'}; - } + } ## end while ( $ingr = $source_sth->fetchrow_hashref... return 1; -} ## end sub import_receipes_table +} ## end sub import_ingredients_table #------------------------------------------------------------- @@ -650,7 +650,7 @@ END_SQL return undef unless $target_dbh->do($sql); return 1; -} ## end sub create_recipe_authors_table +} ## end sub create_ingredient_groups_table #------------------------------------------------------------- @@ -693,11 +693,11 @@ END_SQL return undef; } - } + } ## end while ( $ingr = $source_sth->fetchrow_hashref... return 1; -} ## end sub import_receipes_table +} ## end sub import_ingredient_groups_table #------------------------------------------------------------- @@ -934,7 +934,7 @@ END_SQL while ( $row = $source_sth->fetchrow_hashref() ) { if ( $old_rid != $row->{'recipe_id'} ) { - $i = 1; + $i = 1; $old_rid = $row->{'recipe_id'}; } else { @@ -983,7 +983,7 @@ END_SQL return undef unless $target_dbh->do($sql); return 1; -} ## end sub create_recipe_authors_table +} ## end sub create_recipe_ingredients_table #------------------------------------------------------------- @@ -1024,7 +1024,7 @@ END_SQL while ( $row = $source_sth->fetchrow_hashref() ) { if ( $old_rid != $row->{'recipe_id'} ) { - $i = 1; + $i = 1; $old_rid = $row->{'recipe_id'}; } else { @@ -1036,10 +1036,10 @@ END_SQL push @$qparams, ( $row->{'ingredient_id'} and $row->{'ingredient_id'} > 0 ) ? $map_ingredient_id{ $row->{'ingredient_id'} } : undef; push @$qparams, $row->{'amount'}; push @$qparams, $row->{'amount_offset'} || undef; - push @$qparams, ( $row->{'unit_id'} and $row->{'unit_id'} > 0 ) ? $map_unit_id{$row->{'unit_id'}} : undef; + push @$qparams, ( $row->{'unit_id'} and $row->{'unit_id'} > 0 ) ? $map_unit_id{ $row->{'unit_id'} } : undef; push @$qparams, $i; push @$qparams, ( ( $row->{'group_id'} and $row->{'group_id'} > 0 ) ? $row->{'group_id'} : undef ); - + #$qparams = [ $map_recipe_id{ $row->{'recipe_id'} }, $map_author_id{ $row->{'author_id'} }, $i, ]; unless ( $target_dbh->do( $sql, {}, @$qparams ) ) { @@ -1051,7 +1051,7 @@ END_SQL return 1; -} ## end sub import_recipe_authors_table +} ## end sub import_recipe_ingredients_table #------------------------------------------------------------- @@ -1081,7 +1081,7 @@ END_SQL return 1; -} +} ## end sub create_units_table #------------------------------------------------------------- @@ -1132,11 +1132,11 @@ END_SQL $map_unit_id{ $row->{'id'} } = $target_dbh->{'mysql_insertid'}; - } + } ## end while ( $row = $source_sth->fetchrow_hashref(... return 1; -} +} ## end sub import_units_table #------------------------------------------------------------- @@ -1175,7 +1175,7 @@ INSERT INTO `unit_types` ( ) END_SQL - for my $unit ( @Units ) { + for my $unit (@Units) { $i++; $qparams = [ $i, $unit ]; @@ -1184,11 +1184,11 @@ END_SQL return undef; } - } + } ## end for my $unit (@Units) return 1; -} ## end sub create_yield_types_table +} ## end sub create_unit_types_table #------------------------------------------------------------- -- 2.39.5