X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Commands%2FPA.pm;h=500e93b8e7b65874ca948978566bd566d6307b6e;hb=4d8da97942cdb099117f21fd292b865325a5b897;hp=52fb3a007a1241c3cdc9e234f3c244cc3defde45;hpb=a7e034b3599d41cdf5a158b14bd1715451f89a0c;p=NDIRC.git diff --git a/Commands/PA.pm b/Commands/PA.pm index 52fb3a0..500e93b 100644 --- a/Commands/PA.pm +++ b/Commands/PA.pm @@ -55,11 +55,22 @@ sub p } my $f = $c->model->prepare(q{ -SELECT coords(x,y,z),ruler,planet,race,score,size,value,scorerank,sizerank, - valuerank, xp, xprank, alliance, relationship, nick, planet_status, hit_us, channel -FROM current_planet_stats WHERE (x = $1 AND y = $2 and z = $3) OR nick ILIKE $4 LIMIT 1 +WITH p AS (SELECT pid,coords(x,y,z),ruler,planet,race,score,size,value,scorerank,sizerank, + valuerank, xp, xprank, alliance, relationship, nick, planet_status, hit_us, channel + FROM current_planet_stats + WHERE (x = $1 AND y = $2 and z = $3) OR nick ILIKE $4 LIMIT 1 +), t AS (SELECT tag,bool_or(uid = $5) AS own,max(time) AS time + FROM planet_tags + WHERE pid = (SELECT pid FROM p) + AND ($6 OR uid = $5) + GROUP BY tag + ORDER BY time DESC +), tags AS (SELECT array_to_string(array_agg(tag || CASE WHEN own THEN '*' ELSE '' END),' ') AS tags + FROM t +) +SELECT * FROM p, tags; }); - $f->execute($x,$y,$z,$nick); + $f->execute($x,$y,$z,$nick,$c->uid,$c->check_user_roles(qw/irc_p_intel/)); if (my $planet = $f->fetchrow_hashref()){ for (keys %{$planet}){ $planet->{$_} = valuecolor(1,$planet->{$_}); @@ -68,7 +79,7 @@ FROM current_planet_stats WHERE (x = $1 AND y = $2 and z = $3) OR nick ILIKE $4 if ($c->check_user_roles(qw/irc_p_intel/)){ $ally = "Alliance=$planet->{alliance} ($planet->{relationship}), Nick=$planet->{nick} ($planet->{planet_status}), Channel: $planet->{channel}, Hostile Count: $planet->{hit_us},"; } - $c->reply("$planet->{coords} $planet->{ruler} OF $planet->{planet},$ally Race=$planet->{race}, Score=$planet->{score} ($planet->{scorerank}), Size=$planet->{size} ($planet->{sizerank}), Value=$planet->{value} ($planet->{valuerank}), XP=$planet->{xp} ($planet->{xprank})"); + $c->reply("$planet->{coords} $planet->{ruler} OF $planet->{planet},$ally Race=$planet->{race}, Score=$planet->{score} ($planet->{scorerank}), Size=$planet->{size} ($planet->{sizerank}), Value=$planet->{value} ($planet->{valuerank}), XP=$planet->{xp} ($planet->{xprank}) TAGS: $planet->{tags}"); }else{ $c->reply("Couldn't find planet: $msg"); }