From 728a736e0dcb3876a64c95c52dc0b420972085cf Mon Sep 17 00:00:00 2001 From: Darin McBride Date: Wed, 30 Dec 2015 14:11:57 -0700 Subject: [PATCH] Improve on the admin body-search performance a tiny bit by prefetching more. --- lib/Lacuna/DB/Result/Map/Body.pm | 4 ++-- lib/Lacuna/Web/Admin.pm | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Lacuna/DB/Result/Map/Body.pm b/lib/Lacuna/DB/Result/Map/Body.pm index 96f38011..674c3259 100644 --- a/lib/Lacuna/DB/Result/Map/Body.pm +++ b/lib/Lacuna/DB/Result/Map/Body.pm @@ -225,8 +225,8 @@ sub gas_giant_types {return 5;}; # RELATIONSHIPS __PACKAGE__->belongs_to('star', 'Lacuna::DB::Result::Map::Star', 'star_id'); -__PACKAGE__->belongs_to('alliance', 'Lacuna::DB::Result::Alliance', 'alliance_id', { on_delete => 'set null' }); -__PACKAGE__->belongs_to('empire', 'Lacuna::DB::Result::Empire', 'empire_id'); +__PACKAGE__->belongs_to('alliance', 'Lacuna::DB::Result::Alliance', 'alliance_id', { join_type => 'left', on_delete => 'set null' }); +__PACKAGE__->belongs_to('empire', 'Lacuna::DB::Result::Empire', 'empire_id', {join_type => 'left'}); __PACKAGE__->has_many('_buildings','Lacuna::DB::Result::Building','body_id'); __PACKAGE__->has_many('foreign_ships','Lacuna::DB::Result::Ships','foreign_body_id'); diff --git a/lib/Lacuna/Web/Admin.pm b/lib/Lacuna/Web/Admin.pm index 16812da4..154f874e 100644 --- a/lib/Lacuna/Web/Admin.pm +++ b/lib/Lacuna/Web/Admin.pm @@ -309,7 +309,7 @@ use Encode; sub www_search_bodies { my ($self, $request) = @_; my $page_number = $request->param('page_number') || 1; - my $bodies = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search(undef, {order_by => ['me.name'], rows => 25, page => $page_number, prefetch=>[qw/star/] }); + my $bodies = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search(undef, {order_by => ['me.name'], rows => 25, page => $page_number, prefetch=>[qw/empire star/] }); my $name = decode_utf8($request->param('name') || ''); my $pager = 'name'; @@ -331,10 +331,10 @@ sub www_search_bodies { } my $out = '

Search Bodies

'; $out .= '
'; - $out .= ''; + $out .= '
IdNameXYOZoneStarTypeHappinessEmpire
'; while (my $body = $bodies->next) { - $out .= sprintf('', - $body->id, $body->id, $body->name, $body->x, $body->y, $body->orbit, $body->zone, $body->star_id, $body->star->name,$body->star_id, $body->image_name, kmbtq($body->happiness), + $out .= sprintf('', + $body->id, $body->id, $body->name, $body->x, $body->y, $body->zone, $body->star_id, $body->star->name,$body->star_id, $body->orbit, $body->image_name, kmbtq($body->happiness), $body->empire_id || '', $body->empire_id ? sprintf("%s (%s)",$body->empire->name,$body->empire_id) : '' ); } $out .= '
IdNameXYZoneStarOTypeHappinessEmpire
%s%s%s%s%s%s%s (%d)%s%s%s
%s%s%s%s%s%s (%d)%s%s%s%s
'; -- 2.51.2