X-Git-Url: https://ruin.nu/git/?p=NDIRC.git;a=blobdiff_plain;f=Commands%2FPA.pm;h=7fb453db9f78c513e759d679ad7db1916132a9db;hp=52fb3a007a1241c3cdc9e234f3c244cc3defde45;hb=784ed86eacf5ebed4d3da2ff166b7542ac8f5cd0;hpb=37f76c79c558e1570412e64f99dec3ad407215d2 diff --git a/Commands/PA.pm b/Commands/PA.pm index 52fb3a0..7fb453d 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 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"); }