Show
Ignore:
Timestamp:
02/08/08 02:44:39 (2 years ago)
Author:
eevee
Message:

Database refactoring. Renamed columns and tables to be more consistent and more readable. (#58)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee/Controller/Dex/Search.pm

    r348 r406  
    4949    breed       => { type => 'select', options => [ [ 0 => 'n/a' ], map { [ $_ => ($_ ? "$_: " : '') . $BreedingGroups[$_] ] } 1 .. $#BreedingGroups ], count => 2 }, 
    5050    breed_mode  => { type => 'select', options => [ [ and => 'exactly' ], [ or => 'either of' ] ], default => 'or' }, 
    51     gender      => { type => 'select', options => [ [ any => 'anything' ], [ 255 => 'no gender' ], [ not255 => 'any gender' ], map { [ $_ => lc gender_text($_) ] } qw/0 31 63 127 191 254/ ] }, 
     51    gender_rate => { type => 'select', options => [ [ any => 'anything' ], [ 255 => 'no gender' ], [ not255 => 'any gender' ], map { [ $_ => lc gender_text($_) ] } qw/0 31 63 127 191 254/ ] }, 
    5252    ability     => { type => 'text', size => 20, title => 'Enter the name or number of an ability' }, 
    5353    color       => { type => 'select', options => [qw/any black blue brown gray green pink purple red white yellow/], title => 'I have no explanation for why this is here' }, 
     
    123123            if ($ability) { 
    124124                $joins{pokemon_abilities} = 1; 
    125                 $criteria{'pokemon_abilities.abilityid'} = $ability->id; 
     125                $criteria{'pokemon_abilities.ability_id'} = $ability->id; 
    126126            } 
    127127        } 
     
    142142 
    143143        # BREEDING AND STUFF 
    144         if (defined $p->{gender} and $p->{gender} ne 'any') { 
    145             if ($p->{gender} eq 'not255') { 
    146                 $criteria{'me.gender'} = { '!=' => 255 }; 
     144        if (defined $p->{gender_rate} and $p->{gender_rate} ne 'any') { 
     145            if ($p->{gender_rate} eq 'not255') { 
     146                $criteria{'me.gender_rate'} = { '!=' => 255 }; 
    147147            } else { 
    148                 $criteria{'me.gender'} = $p->{gender}; 
     148                $criteria{'me.gender_rate'} = $p->{gender_rate}; 
    149149            } 
    150150        } 
     
    154154            $criteria{'breeds.breed'} = \@breeds; 
    155155            if ($p->{breed_mode} eq 'and') { 
    156                 $clauses{having}{'COUNT(DISTINCT breeds.pokeid, breeds.breed)'} = scalar @breeds; 
     156                $clauses{having}{'COUNT(DISTINCT breeds.pokemon_id, breeds.breed)'} = scalar @breeds; 
    157157 
    158158                if (@breeds == 1) { 
     
    192192            for my $move (@{ $p->{move} }) { 
    193193                # XXX: show some message if a move is invalid? 
    194                 my $moveid = get_move($move); 
    195                 push @moveids, $moveid if defined $moveid; 
     194                my $move_id = get_move($move); 
     195                push @moveids, $move_id if defined $move_id; 
    196196            } 
    197197            if (@moveids) { 
    198                 $joins{pokemoves} = 1; 
    199                 $criteria{'pokemoves.moveid'} = \@moveids; 
    200                 $clauses{having}{'COUNT(DISTINCT pokemoves.pokeid, pokemoves.moveid)'} = scalar @moveids; 
     198                $joins{pokemon_moves} = 1; 
     199                $criteria{'pokemon_moves.move_id'} = \@moveids; 
     200                $clauses{having}{'COUNT(DISTINCT pokemon_moves.pokemon_id, pokemon_moves.move_id)'} = scalar @moveids; 
    201201 
    202202                if ($p->{move_method}) { 
    203                     $criteria{'pokemoves.method'} = $p->{move_method}; 
     203                    $criteria{'pokemon_moves.method'} = $p->{move_method}; 
    204204                } 
    205205                if ($p->{move_version}) { 
    206                     push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemoves.version)" } Vee::Utils::array($p->{move_version}) ] }; 
     206                    push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemon_moves.versions)" } Vee::Utils::array($p->{move_version}) ] }; 
    207207                } 
    208208            } 
     
    237237 
    238238            if ($evo_stages{base}) { 
    239                 $criteria{'me.evparent'} = 0; 
     239                $criteria{'me.evo_parent_id'} = 0; 
    240240            } 
    241241 
     
    308308}; 
    309309 
    310 for my $col (qw/power acc pp effect_chance priority/) { 
     310for my $col (qw/power accuracy pp effect_chance priority/) { 
    311311    for my $endpoint (keys %endpoints) { 
    312312        $move_search_fields->{ $col . '_' . $endpoint } = { type => 'text', size => 4, maxlength => 3, title => "\u$endpoints{$endpoint}{english} $col" }; 
     
    366366            } 
    367367            if (@pokemonids) { 
    368                 $joins{pokemoves} = 1; 
    369                 $criteria{'pokemoves.pokeid'} = \@pokemonids; 
    370                 $clauses{having}{'COUNT(DISTINCT pokemoves.pokeid, pokemoves.moveid)'} = scalar @pokemonids; 
     368                $joins{pokemon_moves} = 1; 
     369                $criteria{'pokemon_moves.pokemon_id'} = \@pokemonids; 
     370                $clauses{having}{'COUNT(DISTINCT pokemon_moves.pokemon_id, pokemon_moves.move_id)'} = scalar @pokemonids; 
    371371 
    372372                if ($p->{move_method}) { 
    373                     $criteria{'pokemoves.method'} = $p->{move_method}; 
     373                    $criteria{'pokemon_moves.method'} = $p->{move_method}; 
    374374                } 
    375375                if ($p->{move_version}) { 
    376                     push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemoves.version)" } Vee::Utils::array($p->{move_version}) ] }; 
     376                    push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemon_moves.versions)" } Vee::Utils::array($p->{move_version}) ] }; 
    377377                } 
    378378            } 
     
    380380 
    381381        # NUMBERS 
    382         for my $numbar (qw/power acc pp effect_chance priority/) { 
     382        for my $numbar (qw/power accuracy pp effect_chance priority/) { 
    383383            for my $endpoint (keys %endpoints) { 
    384384                my $value = $p->{$numbar . '_' . $endpoint};