X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=NDWeb%2FPages%2FMemberIntel.pm;h=69ced51e09e7abcfb125cffc4ac9a2959ec8dad1;hb=2a48ffc877998e12114d004ac37e0f6456992995;hp=f6ef0c49a0d16ca416a5f7b29fe8de3869f693e5;hpb=a074bd17f5e8ba341a22bbfca1da7093b8351774;p=ndwebbie.git diff --git a/NDWeb/Pages/MemberIntel.pm b/NDWeb/Pages/MemberIntel.pm index f6ef0c4..69ced51 100644 --- a/NDWeb/Pages/MemberIntel.pm +++ b/NDWeb/Pages/MemberIntel.pm @@ -45,43 +45,29 @@ sub render_body { } } - - my $query = $DBH->prepare(intelquery('o.alliance AS oalliance,coords(o.x,o.y,o.z) AS origin, coords(t.x,t.y,t.z) AS target, t.nick',"t.alliance_id = 1 $showticks")); + my $query = $DBH->prepare(q{SELECT u.uid,u.username,u.attack_points, u.defense_points, n.tick + ,count(CASE WHEN i.mission = 'Attack' THEN 1 ELSE NULL END) AS attacks + ,count(CASE WHEN (i.mission = 'Defend' OR i.mission = 'AllyDef') THEN 1 ELSE NULL END) AS defenses + FROM users u + JOIN groupmembers gm USING (uid) + LEFT OUTER JOIN (SELECT DISTINCT ON (planet) planet,tick from scans where type = 'News' ORDER BY planet,tick DESC) n USING (planet) + LEFT OUTER JOIN (SELECT * FROM intel WHERE amount = -1) i ON i.sender = u.planet + LEFT OUTER JOIN current_planet_stats t ON i.target = t.id + WHERE gm.gid = 2 + GROUP BY u.uid,u.username,u.attack_points, u.defense_points,n.tick + ORDER BY attacks DESC,defenses DESC}); $query->execute() or $error .= $DBH->errstr; - my @intellists; - my @incomings; + my @members; my $i = 0; while (my $intel = $query->fetchrow_hashref){ - if ($intel->{ingal}){ - $intel->{missionclass} = 'ingal'; - }else{ - $intel->{missionclass} = $intel->{mission}; - } - $intel->{oalliance} = ' ' unless $intel->{oalliance}; - $i++; - $intel->{ODD} = $i % 2; - push @incomings,$intel; - } - push @intellists,{Message => 'Incoming fleets', Intel => \@incomings, Origin => 1}; - - $query = $DBH->prepare(intelquery('o.nick,coords(o.x,o.y,o.z) AS origin,t.alliance AS talliance,coords(t.x,t.y,t.z) AS target',"o.alliance_id = 1 $showticks")); - $query->execute() or $error .= $DBH->errstr; - my @outgoings; - $i = 0; - while (my $intel = $query->fetchrow_hashref){ - if ($intel->{ingal}){ - $intel->{missionclass} = 'ingal'; - }else{ - $intel->{missionclass} = $intel->{mission}; - } - $intel->{talliance} = ' ' unless $intel->{talliance}; $i++; $intel->{ODD} = $i % 2; - push @outgoings,$intel; + $intel->{OLD} = 'OLD' if (!defined $intel->{tick} || $self->{TICK} > $intel->{tick} + 60); + delete $intel->{tick}; + push @members,$intel; } - push @intellists,{Message => 'Outgoing Fleets', Intel => \@outgoings, Target => 1}; - $BODY->param(IntelLIsts => \@intellists); + $BODY->param(Members => \@members); $BODY->param(Error => $error); return $BODY;