Changeset 19

Show
Ignore:
Timestamp:
02/23/07 21:09:57 (3 years ago)
Author:
eevee
Message:

Removed what I think are the last major database slurps.
Assorted other minor cleanup.

Location:
veekun
Files:
8 modified

Legend:

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

    r13 r19  
    208208    my $s = $c->stash; 
    209209     
    210     $s->{list} = [ $c->model('DBIC::Abilities')->search({ id => { '<' => 200 } }, { order_by => 'id ASC' }) ]; 
     210    $s->{list} = $c->model('DBIC::Abilities')->search({ id => { '<' => 200 } }, { order_by => 'id ASC' }); 
    211211     
    212212    my %pokemon; 
    213     my @pokemon_list = $c->model('DBIC::Pokemon')->search({ 
     213    my $pokemon_list = $c->model('DBIC::Pokemon')->search({ 
    214214        id => { '<=' => $Generations[-1]{maxid} } 
    215215    }, { 
    216216        columns => [qw/id ability1id ability2id/] 
    217217    }); 
    218     for my $poke (@pokemon_list) { 
     218    while (my $poke = $pokemon_list->next) { 
    219219        push @{ $pokemon{$poke->ability1id} }, $poke->id; 
    220220        push @{ $pokemon{$poke->ability2id} }, $poke->id; 
     
    367367    # breeding 
    368368    my ($breed1, $breed2) = ($row->breed1, $row->breed2 || $row->breed1); 
    369     $s->{breedables} = [ $c->model('DBIC::Pokemon')->search( 
     369    $s->{breedables} = $c->model('DBIC::Pokemon')->search( 
    370370        \ "breed1 IN ($breed1, $breed2) OR breed2 IN ($breed1, $breed2)", 
    371371        { columns => [qw/id name gender/], group_by => 'evid', order_by => 'id ASC' } 
    372     ) ]; 
     372    ); 
    373373 
    374374    # moves 
     
    631631 
    632632    my $row = get_row($c, 'Pokemon', $poke); 
    633     # TODO: log these blah blah blah 
    634633    $c->vee_abort('There is no such Pok&eacute;mon ', $poke, '.  If you are messing with my URLs, please stop.  If you came here via a link, please inform its owner that it is invalid.') unless $row; 
    635634 
     
    638637    calculate_stats($c, $row); 
    639638     
    640     my @moves = $c->model('DBIC::PokeMoves')->search({ pokeid => $row->id, -and => \ "FIND_IN_SET('$gen', version)" }); 
     639    my $moves = $c->model('DBIC::PokeMoves')->search({ pokeid => $row->id, -and => \ "FIND_IN_SET('$gen', version)" }); 
    641640    my %moves; 
    642641 
    643     for my $move_row (@moves) { 
     642    while (my $move_row = $moves->next) { 
    644643        push @{ $moves{ $move_row->moveid } }, $move_row; 
    645644    } 
     
    648647    $s->{this} = $row; 
    649648 
    650     $s->{page_title } = $row->name . ' - Strategic Overview'; 
    651     $s->{crumbs     } = [ 
     649    $s->{page_title} = $row->name . ' - Strategic Overview'; 
     650    $s->{crumbs}    = [ 
    652651        '<a href="' . $c->uri('Dex') . '">Pok&eacute;dex</a>', 
    653652        '<a href="' . $c->uri('Dex', 'pokemon_list') . '">Pok&eacute;mon</a>', 
     
    685684 
    686685    my $row = get_row($c, 'Types'); 
    687     $c->vee_abort('There is no such type ', $c->req->args->[0], '.  If you are messing with my URLs, please stop.  If you came here via a link, please inform its owner that it is invalid.') unless $row; 
    688  
    689     $s->{hid}        = $row->internalid + 1; 
    690     $s->{generation} = ($row->name eq 'dark' || $row->name eq 'steel') ? 1 : 0; 
    691  
    692     $s->{page_title } = ucfirst($row->name) . ' - Type #' . $s->{hid}; 
     686    $c->vee_abort('There is no such type ', $c->req->args->[0], '.  If you are messing with my URLs, please stop.  If you came here via a link, please inform its owner that it is invalid.') 
     687        unless $row; 
     688 
     689    $s->{hid}         = $row->internalid + 1; 
     690    $s->{generation}  = ($row->name eq 'dark' || $row->name eq 'steel') ? 1 : 0; 
     691 
     692    $s->{page_title}  = ucfirst($row->name) . ' - Type #' . $s->{hid}; 
    693693    $s->{page_header} = ucfirst $row->name; 
    694     $s->{link_name  } = 'dex'; 
    695     $s->{crumbs     } = [ 
     694    $s->{link_name = 'dex'; 
     695    $s->{crumbs}      = [ 
    696696        '<a href="' . $c->uri('Dex') . '">Pok&eacute;dex</a>', 
    697697        '<a href="' . $c->uri('Dex', 'type_list') . '">Types</a>', 
     
    699699    ]; 
    700700     
    701     $s->{this   } = $row; 
    702     $s->{pokemon} = [ $c->model('DBIC::Pokemon')->search( 
     701    $s->{this}    = $row; 
     702    $s->{pokemon} = $c->model('DBIC::Pokemon')->search( 
    703703        [ type1 => $row->name, type2 => $row->name ], 
    704704        { order_by => 'name ASC', columns => [qw/id name type1 type2/] } 
    705     ) ]; 
    706     $s->{moves  } = [ $c->model('DBIC::Moves')->search({ type => $row->name }, { order_by => 'name ASC', columns => ['id'] }) ]; 
     705    ); 
     706    $s->{moves}   = $c->model('DBIC::Moves')->search({ type => $row->name }, { order_by => 'name ASC', columns => ['id'] }); 
    707707 
    708708    $s->{template} = 'dex/page/type.tt'; 
     
    723723 
    724724    if ($search) { 
    725         # XXX: could use a better sorting mechanism here 
    726         # XXX: substr etc would probably be faster and less regex-injection-prone 
    727         push @suggestions, grep { /^$search/i } @PokemonNames[ 1 .. $#PokemonNames ]; 
    728         push @suggestions, grep { /^$search/i } map { $_->name } @MoveData[ 1 .. $#MoveData ]; 
    729         push @suggestions, grep { /^$search/i } @TypeNames[ 1 .. $#TypeNames ]; 
     725        my $len = length $search; 
     726        $search = lc $search; 
     727        # TODO: could use a better sorting mechanism here 
     728        push @suggestions, grep { $search eq lc substr $_, 0, $len } @PokemonNames[ 1 .. $#PokemonNames ]; 
     729        push @suggestions, grep { $search eq lc substr $_, 0, $len } map { $_->name } @MoveData[ 1 .. $#MoveData ]; 
     730        push @suggestions, grep { $search eq lc substr $_, 0, $len } @TypeNames[ 1 .. $#TypeNames ]; 
    730731    } 
    731732     
     
    751752 
    752753    $string =~ tr/a-z!? //cd; 
    753     $s->{string} = $string; 
    754     $s->{dir} = $dir; 
     754    $s->{string}   = $string; 
     755    $s->{dir}      = $dir; 
    755756    $s->{template} = 'dex/eggs/annon.tt'; 
    756757} 
  • veekun/lib/Vee/Controller/Shoutbox.pm

    r5 r19  
    3737    $s->{extra_css} = 'index'; 
    3838 
    39     $s->{shouts} = [ $c->model('DBIC::Shoutbox')->search( 
    40         undef, 
    41         { 
    42             order_by => 'time DESC', 
    43             prefetch => ['user'], 
    44             rows     => $c->site_opts->{page_sizes}{shoutbox}, 
    45             offset   => $skip, 
    46         } 
    47     ) ]; 
     39    $s->{shouts} = $c->model('DBIC::Shoutbox')->search(undef, { 
     40        order_by => 'time DESC', 
     41        prefetch => ['user'], 
     42        rows     => $c->site_opts->{page_sizes}{shoutbox}, 
     43        offset   => $skip, 
     44    }); 
    4845     
    4946    $s->{shout_total} = $c->model('DBIC::Shoutbox')->count; 
  • veekun/lib/Vee/Controller/Users/Messages.pm

    r9 r19  
    4343    my $skip = $c->req->params->{skip} || 0; 
    4444 
    45     $s->{messages} = [ $c->model('DBIC::Messages')->search({ to_user_id => $c->user->obj->id }, { rows => 50, offset => $skip }) ]; 
     45    $s->{messages} = $c->model('DBIC::Messages')->search({ to_user_id => $c->user->obj->id }, { rows => 50, offset => $skip }); 
    4646     
    4747    $s->{page_title} = 'Messages'; 
  • veekun/templates/dex/list/abilities.tt

    r1 r19  
    55<tr><th> [% Icons.rsefl %] </th><th> Name </th><th> Effect </th><th colspan="2"> Pok&eacute;mon </th></tr> 
    66[% color = 1 %] 
    7 [% FOREACH abil IN list %] 
     7[% WHILE (abil = list.next) %] 
    88<tr class="color[% color %]"> 
    99<td> [% abil.id %] </td> 
  • veekun/templates/dex/page/pokemon.tt

    r1 r19  
    265265<p>Also remember that any gendered Pok&eacute;mon can breed with <a href="[% dex_uri('pokemon', 'ditto') %]">Ditto</a>.</p> 
    266266<p>[ <a href="[% tmp = this.breed2 ? [ this.breed1, this.breed2 ] : this.breed1; c.uri('Dex::Search', 'pokemon_search', { breed_mode => 'or', breed => tmp, baseform => 'on' }) %]">baseform Pok&eacute;mon that can breed with [% this.name %]</a> (equivalent to this list); <a href="[% c.uri('Dex::Search', 'pokemon_search', { breed_mode => 'or', breed => tmp }) %]">all Pok&eacute;mon that can breed with [% this.name %]</a> ]</p> 
    267 [%     FOR pokemon IN breedables %] 
     267[%     WHILE (pokemon = breedables.next) %] 
    268268<a href="[% dex_uri('pokemon', PokemonNames.${pokemon.id}) %]" class="dex-pokelist[% pokemon.gender == 255 ? ' genderless' : '' %]"><img src="/dex-images/icons/[% pokemon.id.pad(3) %].png" alt="[% PokemonNames.${pokemon.id} %]" title="[% PokemonNames.${pokemon.id} %]"/></a> 
    269269[%     END %] 
  • veekun/templates/dex/page/type.tt

    r1 r19  
    5858<h1>Pok&eacute;mon</h1> 
    5959<p><a href="[% c.uri('Dex::Search', 'pokemon_search', { view => 'icons', type_mode => 'any', type => this.name }) %]">This type in the Pok&eacute;mon search</a></p> 
    60 [% FOREACH poke IN pokemon %] 
     60[% WHILE (poke = pokemon.next) %] 
    6161<a href="[% dex_uri('pokemon', poke.name) %]" class="[% IF poke.type2; 'type-'; IF poke.type1 == this.name; poke.type2; ELSE; poke.type1; END; ' '; END %]dex-pokelist"><img src="/dex-images/icons/[% poke.id.pad(3) %].png" alt="[% poke.name %]" title="[% poke.name %]: [% poke.type1 %][% '/' _ poke.type2 IF poke.type2 %]"/></a> 
    6262[% END %] 
  • veekun/templates/shoutbox.tt

    r17 r19  
    1212[% can_ip = c.can_i('ip') %] 
    1313<table class="big shoutlist" cellspacing="0"> 
    14 [% FOREACH s IN shouts %] 
     14[% WHILE (s = shouts.next) %] 
    1515<tr> 
    1616  <td class="center shout-time" title="[% time - s.time | timespan %] ago">[% s.time | date %]</td> 
  • veekun/templates/users/messages/list.tt

    r9 r19  
    33[% color = 1 %] 
    44<table cellspacing="0"> 
    5 [% FOREACH message IN messages %] 
     5[% WHILE (message = messages.next) %] 
    66<tr> 
    77  <td> [% message.sender %] </td> <td> [% message.subject %] </td> <td> [% message.time %] </td>