From bb3a83626c2e24a98f27f93ea6fa42afdb828195 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 19 Feb 2007 15:57:04 +0000 Subject: [PATCH 01/16] update --- stylesheets/thrackan.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stylesheets/thrackan.css b/stylesheets/thrackan.css index 0e274bb..94a950d 100644 --- a/stylesheets/thrackan.css +++ b/stylesheets/thrackan.css @@ -41,6 +41,7 @@ ul.linkbar li { color: white; margin: 0.5em 0; padding: 0.3em; + border: 1px solid white; /*border-right: 1em solid black;*/ } tr.odd { @@ -52,3 +53,6 @@ table.old{ border-collapse: separate; border-color: grey; } +img.graph{ + background: #999999; +} -- 2.39.2 From f628343d025725e197503f845a76a322bf9e7780 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Wed, 21 Feb 2007 09:19:21 +0000 Subject: [PATCH 02/16] show ship classes and add links on def calls overview --- ND/Web/Pages/Calls.pm | 1 + ND/Web/Pages/Check.pm | 18 ++++++++++-------- default.css | 4 ++++ templates/calls.tmpl | 4 ++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ND/Web/Pages/Calls.pm b/ND/Web/Pages/Calls.pm index 73b0916..6cb626a 100644 --- a/ND/Web/Pages/Calls.pm +++ b/ND/Web/Pages/Calls.pm @@ -245,6 +245,7 @@ sub render_body { push @calls,{}; $i = 0; } + $call->{attackers} =~ s{(\d+:\d+:\d+)}{$1}g; $call->{dc} = 'Hostile' unless defined $call->{dc}; $i++; $call->{ODD} = $i % 2; diff --git a/ND/Web/Pages/Check.pm b/ND/Web/Pages/Check.pm index 48186b3..394c8b0 100644 --- a/ND/Web/Pages/Check.pm +++ b/ND/Web/Pages/Check.pm @@ -166,6 +166,14 @@ sub render_body { $scan .= q{}; push @scans, {Scan => $scan}; + $query = $DBH->prepare(q{SELECT DISTINCT ON (type) type,scan_id, tick, scan FROM scans WHERE planet = ? + GROUP BY type,scan_id, tick, scan ORDER BY type,tick DESC}); + $query->execute($planet_id); + my %scans; + while (my($type,$scan_id,$tick,$scan) = $query->fetchrow){ + $scans{$type} = [$scan_id,$tick,$scan]; + } + $query = $DBH->prepare(q{SELECT x,y,z,tick FROM planet_stats WHERE id = ? ORDER BY tick ASC}); $scan = q{

Previous Coords

@@ -181,16 +189,10 @@ sub render_body { } } $scan .= q{}; + $scan .= $scans{'Ship Classes'}->[2] if $scans{'Ship Classes'}; push @scans, {Scan => $scan}; - $query = $DBH->prepare(q{SELECT DISTINCT ON (type) type,scan_id, tick, scan FROM scans WHERE planet = ? - GROUP BY type,scan_id, tick, scan ORDER BY type,tick DESC}); - $query->execute($planet_id); - my %scans; - while (my($type,$scan_id,$tick,$scan) = $query->fetchrow){ - $scans{$type} = [$scan_id,$tick,$scan]; - } - for my $type ('Planet','Jumpgate','Unit','Advanced Unit','Fleet Analysis','Surface Analysis','Technology Analysis','News'){ + for my $type ('Planet','Jumpgate','Unit','Advanced Unit','Surface Analysis','Technology Analysis','Fleet Analysis','News'){ next unless exists $scans{$type}; my $scan_id = $scans{$type}->[0]; my $tick = $scans{$type}->[1]; diff --git a/default.css b/default.css index 5beb2b6..80ea909 100644 --- a/default.css +++ b/default.css @@ -187,6 +187,10 @@ td.MediumPrio{ background: yellow; color: black; } +td.MediumPrio a{ + background: yellow; + color: black; +} td.HighestPrio{ background: green; color: black; diff --git a/templates/calls.tmpl b/templates/calls.tmpl index ebedb75..79cabf3 100644 --- a/templates/calls.tmpl +++ b/templates/calls.tmpl @@ -68,7 +68,7 @@ - + () @@ -91,7 +91,7 @@ - ()-New Day- + ()-New Day- -- 2.39.2 From 0121660a54d34d0e14a4550fa88beef63705e69d Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 26 Feb 2007 10:51:11 +0000 Subject: [PATCH 03/16] delay coords release --- ND/Web/Pages/Raids.pm | 6 +----- ND/Web/XMLPage.pm | 3 ++- raid.js | 4 ++++ templates/raids.tmpl | 1 - templates/raids.xml.tmpl | 1 - 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ND/Web/Pages/Raids.pm b/ND/Web/Pages/Raids.pm index cb2a7ed..7bcb1f4 100644 --- a/ND/Web/Pages/Raids.pm +++ b/ND/Web/Pages/Raids.pm @@ -63,7 +63,6 @@ sub generateClaimXml : method { while (my $target = $targets->fetchrow_hashref){ my %target; $target{Id} = $target->{id}; - $target{Coords} = $target->{id}; my @waves; for (my $i = 1; $i <= $raid->{waves}; $i++){ my %wave; @@ -83,9 +82,6 @@ sub generateClaimXml : method { $claimers = join '/', @claimers; if ($owner){ $wave{Command} = 'Unclaim'; - if ($raid->{released_coords}){ - $target{Coords} = $DBH->selectrow_array('SELECT coords(x,y,z) FROM current_planet_stats WHERE id = ?',undef,$target->{planet}); - } }elsif ($joinable){ $wave{Command} = 'Join'; }else{ @@ -261,7 +257,7 @@ sub render_body { for (my $i = 1; $i <= $raid->{waves}; $i++){ my $roids = floor(0.25*$size); $size -= $roids; - my $xp; + my $xp = 0; if ($planet){ $xp = max(0,floor($roids * 10 * (min(2,$target{Score}/$planet->{score}) + min(2,$target{Value}/$planet->{value})-1))); } diff --git a/ND/Web/XMLPage.pm b/ND/Web/XMLPage.pm index d1804f1..9e5fce6 100644 --- a/ND/Web/XMLPage.pm +++ b/ND/Web/XMLPage.pm @@ -39,7 +39,8 @@ sub process : method { sub listTargets () : method { my $self = shift; my $DBH = $self->{DBH}; - my $query = $DBH->prepare(qq{SELECT t.id, r.id AS raid, r.tick+c.wave-1 AS landingtick, released_coords, coords(x,y,z),c.launched,c.wave,c.joinable + my $query = $DBH->prepare(qq{SELECT t.id, r.id AS raid, r.tick+c.wave-1 AS landingtick, + (released_coords AND old_claim(timestamp)) AS released_coords, coords(x,y,z),c.launched,c.wave,c.joinable FROM raid_claims c JOIN raid_targets t ON c.target = t.id JOIN raids r ON t.raid = r.id diff --git a/raid.js b/raid.js index a4179ac..8bec240 100644 --- a/raid.js +++ b/raid.js @@ -139,12 +139,16 @@ function updateClaims(dataSource,xmlthingy,timestamp){ b.setAttribute("onclick", "claim('"+dataSource+"',"+target+","+wave+",'"+command+"');"); obj.appendChild(b); } + /*@cc_on obj.innerHTML = obj.innerHTML; // IE doesn't understand unless you tell it twice + @*/ } + /* obj = document.getElementById("coords"+target); var coords = targets[i].getElementsByTagName("coords");; if (obj) obj.innerHTML = coords[0].firstChild.nodeValue; + */ } if (timestamp){ timestamp = xmlthingy.getElementsByTagName("timestamp"); diff --git a/templates/raids.tmpl b/templates/raids.tmpl index eaf6b19..4b3d109 100644 --- a/templates/raids.tmpl +++ b/templates/raids.tmpl @@ -84,7 +84,6 @@

-

Target coords:

diff --git a/templates/raids.xml.tmpl b/templates/raids.xml.tmpl index bf67668..804a379 100644 --- a/templates/raids.xml.tmpl +++ b/templates/raids.xml.tmpl @@ -12,7 +12,6 @@
- -- 2.39.2 From 88b7705d46b3f123c7a51966cc779f189bdff63b Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 26 Feb 2007 10:58:24 +0000 Subject: [PATCH 04/16] inform about coords delay --- templates/raids.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/raids.tmpl b/templates/raids.tmpl index 4b3d109..82e1df9 100644 --- a/templates/raids.tmpl +++ b/templates/raids.tmpl @@ -26,6 +26,7 @@
Message

REMEMBER TO PASTE LAUNCH CONFIRMATION IF YOU WANT AN ATTACK POINT

DO NOT JOIN A WAVE UNLESS YOU HAVE PERMISSION FROM THE PERSON WHO CLAIMED IT

+

COORDS ARE NOT SHOWN UNTIL AT LEAST 10 MIN AFTER YOUR CLAIM

Landing tick first wave:

-- 2.39.2 From bdf6b83e09a707b91bd83383994372afd5fd5fcd Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 26 Feb 2007 11:00:12 +0000 Subject: [PATCH 05/16] pink is not good on light background --- templates/raids.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/raids.tmpl b/templates/raids.tmpl index 82e1df9..4c4d564 100644 --- a/templates/raids.tmpl +++ b/templates/raids.tmpl @@ -26,7 +26,7 @@
Message

REMEMBER TO PASTE LAUNCH CONFIRMATION IF YOU WANT AN ATTACK POINT

DO NOT JOIN A WAVE UNLESS YOU HAVE PERMISSION FROM THE PERSON WHO CLAIMED IT

-

COORDS ARE NOT SHOWN UNTIL AT LEAST 10 MIN AFTER YOUR CLAIM

+

COORDS ARE NOT SHOWN UNTIL AT LEAST 10 MIN AFTER YOUR CLAIM

Landing tick first wave:

-- 2.39.2 From 0590345742e647633ea9817a7bd28129d3f1f3f4 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Tue, 27 Feb 2007 13:09:22 +0000 Subject: [PATCH 06/16] more advanced .xp --- ND/IRC/PA.pm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ND/IRC/PA.pm b/ND/IRC/PA.pm index 30e7fdc..48751e4 100644 --- a/ND/IRC/PA.pm +++ b/ND/IRC/PA.pm @@ -140,16 +140,26 @@ FROM ship_stats WHERE name ILIKE ? } sub calcXp { - my ($x,$y,$z,$roids) = @_; + my ($x,$y,$z,$roids,$cap) = @_; + + print "$roids:$cap:"; my ($avalue,$ascore) = $ND::DBH->selectrow_array(q{ SELECT value,score FROM current_planet_stats WHERE id = (SELECT planet FROM users WHERE hostmask ILIKE ?); }, undef, $ND::address); - my ($tvalue,$tscore) = $ND::DBH->selectrow_array(q{ - SELECT value,score FROM current_planet_stats WHERE - x = ? AND y = ? and z = ?; + my ($tvalue,$tscore,$tsize) = $ND::DBH->selectrow_array(q{ + SELECT value,score,size FROM current_planet_stats WHERE + x = ? AND y = ? and z = ?; }, undef, $x,$y,$z); + $cap = 0.25 unless $cap; + unless($roids){ + $roids = int($tsize*$cap); + }elsif ($roids < 10){ + $tsize *= .75**($roids-1); + $roids = int($cap*$tsize); + } + $tsize -= $roids; unless (defined $avalue && defined $ascore){ $ND::server->command("notice $ND::target You don't have a planet specified"); return; @@ -160,7 +170,9 @@ sub calcXp { } my $xp = int(max($roids * 10 * (min(2,$tscore/$ascore) + min(2,$tvalue/$avalue) - 1),0)); my $score = 60 * $xp; - $ND::server->command("notice $ND::target You will gain $ND::B$xp$ND::B XP, $ND::B$score$ND::B score, if you steal $roids roids from $x:$y:$z"); + my $value = $roids*200; + my $totscore = prettyValue($score + $value); + $ND::server->command("notice $ND::target You will gain $ND::B$xp$ND::B XP, $ND::B$score$ND::B score, if you steal $roids roids ($ND::B$value$ND::B value), from $ND::B$x:$y:$z$ND::B, who will have $ND::B$tsize$ND::B roids left, total score gain will be: $ND::B$totscore$ND::B in total,"); } 1; -- 2.39.2 From 4f0ba7a3042745559e2ddb2abe7cef063399c606 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Fri, 2 Mar 2007 11:49:40 +0000 Subject: [PATCH 07/16] alliance rankings --- ND/Web/Pages/AllianceRankings.pm | 110 +++++++++++++++++++++++++++++++ startup.pl | 1 + templates/alliancerankings.tmpl | 37 +++++++++++ templates/skel.tmpl | 1 + 4 files changed, 149 insertions(+) create mode 100644 ND/Web/Pages/AllianceRankings.pm create mode 100644 templates/alliancerankings.tmpl diff --git a/ND/Web/Pages/AllianceRankings.pm b/ND/Web/Pages/AllianceRankings.pm new file mode 100644 index 0000000..bd0a2d5 --- /dev/null +++ b/ND/Web/Pages/AllianceRankings.pm @@ -0,0 +1,110 @@ +#************************************************************************** +# Copyright (C) 2006 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ + +package ND::Web::Pages::AllianceRankings; +use strict; +use warnings FATAL => 'all'; +use CGI qw/:standard/; +use ND::Web::Include; + +use base qw/ND::Web::XMLPage/; + +$ND::Web::Page::PAGES{alliancerankings} = __PACKAGE__; + +sub parse { + #TODO: Need to fix some links first + #if ($uri =~ m{^/[^/]+/(\w+)}){ + # param('order',$1); + #} +} + +sub render_body { + my $self = shift; + my ($BODY) = @_; + $self->{TITLE} = 'Top Alliances'; + my $DBH = $self->{DBH}; + + return $self->noAccess unless $self->isMember; + + my $error = ''; + + $BODY->param(isHC => $self->isHC); + + my $offset = 0; + if (defined param('offset') && param('offset') =~ /^(\d+)$/){ + $offset = $1; + } + $BODY->param(Offset => $offset); + $BODY->param(PrevOffset => $offset - 100); + $BODY->param(NextOffset => $offset + 100); + + my $order = 'scorerank'; + if (defined param('order') && param('order') =~ /^(scorerank|sizerank|members|avgsize|avgscore)$/){ + $order = $1; + } + $BODY->param(Order => $order); + $order .= ' DESC' unless $order =~ /rank$/; + + + #my $extra_columns = ''; + #if ($self->isHC){ + # $extra_columns = ",alliance_status,hit_us, alliance,relationship,nick"; + #} + my $query = $DBH->prepare(qq{SELECT a.name, + size, size_gain, size_gain_day, + score,score_gain,score_gain_day, + avgsize,avgsize_gain,avgsize_gain_day, + avgscore,avgscore_gain,avgscore_gain_day, + sizerank,sizerank_gain,sizerank_gain_day, + scorerank,scorerank_gain,scorerank_gain_day, + members,members_gain,members_gain_day + FROM + ( SELECT id, members,members_gain,members_gain_day, size, score, (size/members) AS avgsize, (score/members) AS avgscore, sizerank, scorerank, size_gain, score_gain, (size_gain/members) AS avgsize_gain, (score_gain/members) AS avgscore_gain, sizerank_gain, scorerank_gain, size_gain_day, score_gain_day, (size_gain_day/members) AS avgsize_gain_day, (score_gain_day/members) AS avgscore_gain_day, sizerank_gain_day, scorerank_gain_day + FROM alliance_stats WHERE tick = (( SELECT max(tick) AS max FROM alliance_stats))) ast + NATURAL JOIN alliances a + ORDER BY $order LIMIT 100 OFFSET ?}); + $query->execute($offset) or $error .= p($DBH->errstr); + my @alliances; + my $i = 0; + while (my $alliance = $query->fetchrow_hashref){ + for my $type (qw/members size score avgsize avgscore/){ + #$alliance->{$type} = prettyValue($alliance->{$type}); + next unless defined $alliance->{"${type}_gain_day"}; + $alliance->{"${type}img"} = 'stay'; + $alliance->{"${type}img"} = 'up' if $alliance->{"${type}_gain_day"} > 0; + $alliance->{"${type}img"} = 'down' if $alliance->{"${type}_gain_day"} < 0; + if( $type eq 'size' || $type eq 'score'){ + $alliance->{"${type}rankimg"} = 'stay'; + $alliance->{"${type}rankimg"} = 'up' if $alliance->{"${type}rank_gain_day"} < 0; + $alliance->{"${type}rankimg"} = 'down' if $alliance->{"${type}rank_gain_day"} > 0; + } + for my $type ($type,"${type}_gain","${type}_gain_day"){ + $alliance->{$type} =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; #Add comma for ever 3 digits, i.e. 1000 => 1,000 + } + } + $i++; + $alliance->{ODD} = $i % 2; + push @alliances,$alliance; + } + $BODY->param(Alliances => \@alliances); + $BODY->param(Error => $error); + return $BODY; +} + +1; diff --git a/startup.pl b/startup.pl index e8afdae..9f8403a 100644 --- a/startup.pl +++ b/startup.pl @@ -52,6 +52,7 @@ use ND::Web::Pages::Settings; use ND::Web::Pages::Graph; use ND::Web::Pages::Mail; use ND::Web::Pages::HostileAlliances; +use ND::Web::Pages::AllianceRankings; diff --git a/templates/alliancerankings.tmpl b/templates/alliancerankings.tmpl new file mode 100644 index 0000000..847b0cb --- /dev/null +++ b/templates/alliancerankings.tmpl @@ -0,0 +1,37 @@ + +

Previous 100 + Next 100

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rank
SizeScoreNameMembersSizeScoreAvg SizeAvg Score
<TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=MembersImg> <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=AvgSizeImg> <TMPL_VAR NAME=AvgScoreImg>
+

Previous 100 + Next 100

diff --git a/templates/skel.tmpl b/templates/skel.tmpl index 37f8cdf..573adc8 100644 --- a/templates/skel.tmpl +++ b/templates/skel.tmpl @@ -28,6 +28,7 @@
  • CovOp targets
  • Distwhores
  • Planet Rankings
  • +
  • Alliance Rankings
  • Request defense
  • -- 2.39.2 From 4aa8043871fac60e6a5038489f6bc05ab2f3bd78 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 3 Mar 2007 10:38:49 +0000 Subject: [PATCH 08/16] remove debug output, and truncate the target size --- ND/IRC/PA.pm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ND/IRC/PA.pm b/ND/IRC/PA.pm index 48751e4..29bdb77 100644 --- a/ND/IRC/PA.pm +++ b/ND/IRC/PA.pm @@ -142,8 +142,6 @@ FROM ship_stats WHERE name ILIKE ? sub calcXp { my ($x,$y,$z,$roids,$cap) = @_; - print "$roids:$cap:"; - my ($avalue,$ascore) = $ND::DBH->selectrow_array(q{ SELECT value,score FROM current_planet_stats WHERE id = (SELECT planet FROM users WHERE hostmask ILIKE ?); @@ -156,7 +154,7 @@ sub calcXp { unless($roids){ $roids = int($tsize*$cap); }elsif ($roids < 10){ - $tsize *= .75**($roids-1); + $tsize *= int(.75**($roids-1)); $roids = int($cap*$tsize); } $tsize -= $roids; -- 2.39.2 From f6cfe40e6a8da61229131a2d38a2535ae66da359 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 3 Mar 2007 11:27:58 +0000 Subject: [PATCH 09/16] gal rankings and fixed a bug with gal graph caching --- ND/Web/Pages/GalaxyRankings.pm | 109 +++++++++++++++++++++++++++++++++ ND/Web/Pages/Graph.pm | 6 +- startup.pl | 1 + templates/galaxyrankings.tmpl | 41 +++++++++++++ templates/skel.tmpl | 1 + 5 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 ND/Web/Pages/GalaxyRankings.pm create mode 100644 templates/galaxyrankings.tmpl diff --git a/ND/Web/Pages/GalaxyRankings.pm b/ND/Web/Pages/GalaxyRankings.pm new file mode 100644 index 0000000..d09c8e5 --- /dev/null +++ b/ND/Web/Pages/GalaxyRankings.pm @@ -0,0 +1,109 @@ +#************************************************************************** +# Copyright (C) 2006 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ + +package ND::Web::Pages::GalaxyRankings; +use strict; +use warnings FATAL => 'all'; +use CGI qw/:standard/; +use ND::Web::Include; + +use base qw/ND::Web::XMLPage/; + +$ND::Web::Page::PAGES{galaxyrankings} = __PACKAGE__; + +sub parse { + #TODO: Need to fix some links first + #if ($uri =~ m{^/[^/]+/(\w+)}){ + # param('order',$1); + #} +} + +sub render_body { + my $self = shift; + my ($BODY) = @_; + $self->{TITLE} = 'Top Galaxies'; + my $DBH = $self->{DBH}; + + return $self->noAccess unless $self->isMember; + + my $error = ''; + + $BODY->param(isHC => $self->isHC); + + my $offset = 0; + if (defined param('offset') && param('offset') =~ /^(\d+)$/){ + $offset = $1; + } + $BODY->param(Offset => $offset); + $BODY->param(PrevOffset => $offset - 100); + $BODY->param(NextOffset => $offset + 100); + + my $order = 'scorerank'; + if (defined param('order') && param('order') =~ /^(scorerank|sizerank|planets|xprank|avgscore)$/){ + $order = $1; + } + $BODY->param(Order => $order); + $order .= ' DESC' unless $order =~ /rank$/; + + + #my $extra_columns = ''; + #if ($self->isHC){ + # $extra_columns = ",galaxy_status,hit_us, galaxy,relationship,nick"; + #} + my $query = $DBH->prepare(qq{SELECT x,y, + size, size_gain, size_gain_day, + score,score_gain,score_gain_day, + value,value_gain,value_gain_day, + xp,xp_gain,xp_gain_day, + sizerank,sizerank_gain,sizerank_gain_day, + scorerank,scorerank_gain,scorerank_gain_day, + valuerank,valuerank_gain,valuerank_gain_day, + xprank,xprank_gain,xprank_gain_day, + planets,planets_gain,planets_gain_day + FROM galaxies g WHERE tick = ( SELECT max(tick) AS max FROM galaxies) + ORDER BY $order LIMIT 100 OFFSET ?}); + $query->execute($offset) or $error .= p($DBH->errstr); + my @galaxies; + my $i = 0; + while (my $galaxy = $query->fetchrow_hashref){ + for my $type (qw/planets size score xp value/){ + #$galaxy->{$type} = prettyValue($galaxy->{$type}); + next unless defined $galaxy->{"${type}_gain_day"}; + $galaxy->{"${type}img"} = 'stay'; + $galaxy->{"${type}img"} = 'up' if $galaxy->{"${type}_gain_day"} > 0; + $galaxy->{"${type}img"} = 'down' if $galaxy->{"${type}_gain_day"} < 0; + unless( $type eq 'planets'){ + $galaxy->{"${type}rankimg"} = 'stay'; + $galaxy->{"${type}rankimg"} = 'up' if $galaxy->{"${type}rank_gain_day"} < 0; + $galaxy->{"${type}rankimg"} = 'down' if $galaxy->{"${type}rank_gain_day"} > 0; + } + for my $type ($type,"${type}_gain","${type}_gain_day"){ + $galaxy->{$type} =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; #Add comma for ever 3 digits, i.e. 1000 => 1,000 + } + } + $i++; + $galaxy->{ODD} = $i % 2; + push @galaxies,$galaxy; + } + $BODY->param(Galaxies => \@galaxies); + $BODY->param(Error => $error); + return $BODY; +} + +1; diff --git a/ND/Web/Pages/Graph.pm b/ND/Web/Pages/Graph.pm index d757d13..d034353 100644 --- a/ND/Web/Pages/Graph.pm +++ b/ND/Web/Pages/Graph.pm @@ -53,7 +53,7 @@ sub render_body { ($req{id}) = $DBH->selectrow_array(q{SELECT planetid($1,$2,$3,$4)},undef,$1,$2,$3,$tick); }else{ $type = "gal$type"; - $req{id} = 100*$2+$2; + $req{id} = 100*$1+$2; } } }elsif($self->{URI} =~ m{^/\w+/(alliance(?:avg)?)/(\d+)}){ @@ -96,7 +96,7 @@ sub render_body { $graph_settings{y_max_value} = 0; } $query->execute($x,$y,$z,$tick) or die $DBH->errstr; - $graph_settings{title} = $type; + $graph_settings{title} = "$type: $x:$y:$z"; $graph_settings{two_axes} = 1; $graph_settings{use_axis} = [2,1,2,2]; $img = graphFromQuery 500,300,\%graph_settings,$query; @@ -111,7 +111,7 @@ sub render_body { $graph_settings{y_max_value} = 0; } $query->execute($x,$y) or die $DBH->errstr; - $graph_settings{title} = $type; + $graph_settings{title} = "$type: $x:$y"; $graph_settings{two_axes} = 1; $graph_settings{use_axis} = [2,1,2,2]; $img = graphFromQuery 500,300,\%graph_settings,$query; diff --git a/startup.pl b/startup.pl index 9f8403a..996b3b7 100644 --- a/startup.pl +++ b/startup.pl @@ -53,6 +53,7 @@ use ND::Web::Pages::Graph; use ND::Web::Pages::Mail; use ND::Web::Pages::HostileAlliances; use ND::Web::Pages::AllianceRankings; +use ND::Web::Pages::GalaxyRankings; diff --git a/templates/galaxyrankings.tmpl b/templates/galaxyrankings.tmpl new file mode 100644 index 0000000..ef9b532 --- /dev/null +++ b/templates/galaxyrankings.tmpl @@ -0,0 +1,41 @@ + +

    Previous 100 + Next 100

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Rank
    SizeScoreValueXPCoordsPlanetsSizeScoreValueXP
    <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=ValueImg> <TMPL_VAR NAME=XPImg> : <TMPL_VAR NAME=PlanetsImg> <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=ValueImg> <TMPL_VAR NAME=XPImg>
    +

    Previous 100 + Next 100

    diff --git a/templates/skel.tmpl b/templates/skel.tmpl index 573adc8..2be8aee 100644 --- a/templates/skel.tmpl +++ b/templates/skel.tmpl @@ -29,6 +29,7 @@
  • Distwhores
  • Planet Rankings
  • Alliance Rankings
  • +
  • Galaxy Rankings
  • Request defense
  • -- 2.39.2 From 5bdf7f1c03127ec37bd29852ebc0279431ad93aa Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 3 Mar 2007 11:50:08 +0000 Subject: [PATCH 10/16] show some more galaxy information --- ND/Web/Pages/Check.pm | 42 +++++++++++++++++++++++++++++++++++++++++- templates/check.tmpl | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/ND/Web/Pages/Check.pm b/ND/Web/Pages/Check.pm index 394c8b0..f68c949 100644 --- a/ND/Web/Pages/Check.pm +++ b/ND/Web/Pages/Check.pm @@ -124,7 +124,7 @@ sub render_body { delete $planet->{id}; push @planets,$planet; } - $BODY->param(Planets => \@planets); + $BODY->param(GPlanets => \@planets); if ($z && $planet_id){ $BODY->param(OnePlanet => 1); @@ -207,6 +207,46 @@ sub render_body { $BODY->param(Scans => \@scans); } + $query = $DBH->prepare(q{SELECT x,y, + size, size_gain, size_gain_day, + score,score_gain,score_gain_day, + value,value_gain,value_gain_day, + xp,xp_gain,xp_gain_day, + sizerank,sizerank_gain,sizerank_gain_day, + scorerank,scorerank_gain,scorerank_gain_day, + valuerank,valuerank_gain,valuerank_gain_day, + xprank,xprank_gain,xprank_gain_day, + planets,planets_gain,planets_gain_day + FROM galaxies g + WHERE tick = ( SELECT max(tick) AS max FROM galaxies) + AND x = $1 AND y = $2 + }); + $query->execute($x,$y) or $ND::ERROR .= p($DBH->errstr); + + my @galaxies; + $i = 0; + while (my $galaxy = $query->fetchrow_hashref){ + for my $type (qw/planets size score xp value/){ + #$galaxy->{$type} = prettyValue($galaxy->{$type}); + next unless defined $galaxy->{"${type}_gain_day"}; + $galaxy->{"${type}img"} = 'stay'; + $galaxy->{"${type}img"} = 'up' if $galaxy->{"${type}_gain_day"} > 0; + $galaxy->{"${type}img"} = 'down' if $galaxy->{"${type}_gain_day"} < 0; + unless( $type eq 'planets'){ + $galaxy->{"${type}rankimg"} = 'stay'; + $galaxy->{"${type}rankimg"} = 'up' if $galaxy->{"${type}rank_gain_day"} < 0; + $galaxy->{"${type}rankimg"} = 'down' if $galaxy->{"${type}rank_gain_day"} > 0; + } + for my $type ($type,"${type}_gain","${type}_gain_day"){ + $galaxy->{$type} =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; #Add comma for ever 3 digits, i.e. 1000 => 1,000 + } + } + $i++; + $galaxy->{ODD} = $i % 2; + push @galaxies,$galaxy; + } + $BODY->param(Galaxies => \@galaxies); + return $BODY; } diff --git a/templates/check.tmpl b/templates/check.tmpl index efdd9ab..6c12706 100644 --- a/templates/check.tmpl +++ b/templates/check.tmpl @@ -1,11 +1,45 @@

    Do arbiter check on gal

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Rank
    SizeScoreValueXPCoordsPlanetsSizeScoreValueXP
    <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=ValueImg> <TMPL_VAR NAME=XPImg> : <TMPL_VAR NAME=PlanetsImg> <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=ValueImg> <TMPL_VAR NAME=XPImg>
    + - + -- 2.39.2 From 128923b3f33de096c7af010403961a4db3e6c874 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 3 Mar 2007 12:31:19 +0000 Subject: [PATCH 11/16] possible to unclaim and block waves --- ND/Web/Pages/EditRaid.pm | 27 +++++++++++++++++++++++++++ templates/editRaid.tmpl | 8 ++++++++ 2 files changed, 35 insertions(+) diff --git a/ND/Web/Pages/EditRaid.pm b/ND/Web/Pages/EditRaid.pm index 343021a..faf9780 100644 --- a/ND/Web/Pages/EditRaid.pm +++ b/ND/Web/Pages/EditRaid.pm @@ -144,6 +144,15 @@ sub render_body { $error .= "

    Something went wrong: ".$DBH->errstr."

    "; } } + if ($raid && param('block') && param('target')){ + $DBH->do(q{INSERT INTO raid_claims (target,uid,wave) VALUES(?,-2,?)} + ,undef,param('target'),param('block')); + } + if ($raid && param('unclaim') && param('target')){ + $DBH->do(q{DELETE FROM raid_claims WHERE target = ? AND wave = ?} + ,undef,param('target'),param('unclaim')); + log_message $ND::UID,"BC unclaimed target ".param('target')." wave ".param('unclaim')."."; + } my $groups = $DBH->prepare(q{SELECT g.gid,g.groupname,raid FROM groups g LEFT OUTER JOIN (SELECT gid,raid FROM raid_access WHERE raid = ?) AS ra ON g.gid = ra.gid WHERE g.attack}); $groups->execute($raid ? $raid->{id} : undef); @@ -189,9 +198,27 @@ sub render_body { FROM current_planet_stats p JOIN raid_targets r ON p.id = r.planet WHERE r.raid = ? ORDER BY $order}); + my $claims = $DBH->prepare(qq{ SELECT username,launched FROM raid_claims + NATURAL JOIN users WHERE target = ? AND wave = ?}); $targetquery->execute($raid->{id}) or $error .= $DBH->errstr; my @targets; while (my $target = $targetquery->fetchrow_hashref){ + my @waves; + for my $i (1 .. $raid->{waves}){ + $claims->execute($target->{id},$i); + my $claimers; + if ($claims->rows != 0){ + my $owner = 0; + my @claimers; + while (my $claim = $claims->fetchrow_hashref){ + $claim->{username} .= '*' if ($claim->{launched}); + push @claimers,$claim->{username}; + } + $claimers = join '/', @claimers; + } + push @waves,{Wave => $i, Claimers => $claimers}; + } + $target->{waves} = \@waves; push @targets,$target; } $BODY->param(Targets => \@targets); diff --git a/templates/editRaid.tmpl b/templates/editRaid.tmpl index ced3aec..94ed903 100644 --- a/templates/editRaid.tmpl +++ b/templates/editRaid.tmpl @@ -90,6 +90,14 @@

     
    + + +

    Unclaim wave ()

    + +

    Block wave

    +
    +
    +
     

    Remove

    -- 2.39.2 From c68b4d69e4fe4b037110aeab3ee8a98248b846a6 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Tue, 6 Mar 2007 08:20:54 +0000 Subject: [PATCH 12/16] put attackers and buttons in a box --- templates/calls.tmpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/calls.tmpl b/templates/calls.tmpl index 79cabf3..14cf190 100644 --- a/templates/calls.tmpl +++ b/templates/calls.tmpl @@ -50,7 +50,7 @@

    -

    Attackers:

    +
    Attackers:
    @@ -84,7 +84,8 @@

    - + +
    Rank
    SizeScoreValue XPCoordsPlanetRaceSizeScoreValue XPFleet (Resouce) valueNickHit usAlliance
    <TMPL_VAR NAME=SizeImg>
    -- 2.39.2 From 0946c8be97d9440c68c3c12ff4ba9128f8b6fb7b Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 12 Mar 2007 08:38:50 +0000 Subject: [PATCH 13/16] target list, and bcc --- ND/Web/Pages/Mail.pm | 2 +- ND/Web/Pages/TargetList.pm | 79 ++++++++++++++++++++++++++++++++++++++ startup.pl | 1 + templates/targetList.tmpl | 27 +++++++++++++ 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 ND/Web/Pages/TargetList.pm create mode 100644 templates/targetList.tmpl diff --git a/ND/Web/Pages/Mail.pm b/ND/Web/Pages/Mail.pm index 98f5c2e..858d0de 100644 --- a/ND/Web/Pages/Mail.pm +++ b/ND/Web/Pages/Mail.pm @@ -59,7 +59,7 @@ sub render_body { my %mail = ( smtp => 'ruin.nu', - To => (join ',',@emails), + BCC => (join ',',@emails), From => 'NewDawn Command ', 'Content-type' => 'text/plain; charset="UTF-8"', Subject => param('subject'), diff --git a/ND/Web/Pages/TargetList.pm b/ND/Web/Pages/TargetList.pm new file mode 100644 index 0000000..67c4653 --- /dev/null +++ b/ND/Web/Pages/TargetList.pm @@ -0,0 +1,79 @@ +#************************************************************************** +# Copyright (C) 2006 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ + +package ND::Web::Pages::TargetList; +use strict; +use warnings FATAL => 'all'; +use ND::Include; +use CGI qw/:standard/; +use ND::Web::Include; + +use base qw/ND::Web::XMLPage/; + +$ND::Web::Page::PAGES{targetList} = __PACKAGE__; + +sub render_body { + my $self = shift; + my ($BODY) = @_; + $self->{TITLE} = 'NF Value'; + my $DBH = $self->{DBH}; + + return $self->noAccess unless $self->isHC; + + my $order = 'nfvalue'; + if (local $_ = param('order')){ + if (/^(size|value|score|xp)$/){ + $order = "$1 DESC"; + }elsif (/^(nfvalue|nfvalue2)$/){ + $order = "$1 ASC"; + } + } + + my $alliances = '15'; + if (param('alliances') && param('alliances') =~ /^([\d,]+)$/){ + $alliances = $1; + } + my $query = $DBH->prepare(qq{ +SELECT coords(p.x,p.y,p.z),p.alliance, p.score, p.value, p.size, p.xp,nfvalue, nfvalue - sum(pa.value) AS nfvalue2, p.race +FROM current_planet_stats p + JOIN (SELECT g.x,g.y, sum(p.value) AS nfvalue + FROM galaxies g join current_planet_stats p on g.x = p.x AND g.y = p.y + WHERE g.tick = (SELECT max(tick) from galaxies) + AND ((planet_status IS NULL OR NOT planet_status IN ('Friendly','NAP')) AND (relationship IS NULL OR NOT relationship IN ('Friendly','NAP'))) + GROUP BY g.x,g.y + ) g ON p.x = g.x AND p.y = g.y + JOIN current_planet_stats pa ON pa.x = g.x AND pa.y = g.y +WHERE p.alliance_id IN ($alliances) + AND pa.alliance_id IN ($alliances) +GROUP BY p.x,p.y,p.z,p.alliance, p.score, p.value, p.size, p.xp, nfvalue,p.race +ORDER BY $order + }); + $query->execute; + my @alliances; + my $i = 0; + while (my $alliance = $query->fetchrow_hashref){ + $i++; + $alliance->{ODD} = $i % 2; + push @alliances,$alliance; + } + $BODY->param(Alliances => \@alliances); + + return $BODY; +} +1; diff --git a/startup.pl b/startup.pl index 996b3b7..663c621 100644 --- a/startup.pl +++ b/startup.pl @@ -54,6 +54,7 @@ use ND::Web::Pages::Mail; use ND::Web::Pages::HostileAlliances; use ND::Web::Pages::AllianceRankings; use ND::Web::Pages::GalaxyRankings; +use ND::Web::Pages::TargetList; diff --git a/templates/targetList.tmpl b/templates/targetList.tmpl new file mode 100644 index 0000000..f61701a --- /dev/null +++ b/templates/targetList.tmpl @@ -0,0 +1,27 @@ + +
    CallMember (def points)Landing tickRacesAmountShiptypesCurrent etaInital etaAllianceAttackers
    + + + + + + + + + + + + + + + + + + + + + + + + +
    CoordsAllianceRaceScoreValueXPSizeNF ValueNF Value - Ally Value
    -- 2.39.2 From c5f1b93c5911285110c078decefc2447a92a8d9a Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Tue, 13 Mar 2007 11:36:49 +0000 Subject: [PATCH 14/16] improved raid editing --- ND/Web/Pages/EditRaid.pm | 55 ++++++++++++++++++++++++++++++++-------- templates/editRaid.tmpl | 35 ++++++++++++++----------- 2 files changed, 64 insertions(+), 26 deletions(-) diff --git a/ND/Web/Pages/EditRaid.pm b/ND/Web/Pages/EditRaid.pm index faf9780..16eab5e 100644 --- a/ND/Web/Pages/EditRaid.pm +++ b/ND/Web/Pages/EditRaid.pm @@ -103,7 +103,7 @@ sub render_body { SELECT ?, id FROM current_planet_stats p WHERE x = ? AND y = ? AND COALESCE(z = ?,TRUE) $sizelimit)}); while ($targets =~ m/(\d+):(\d+)(?::(\d+))?/g){ unless ($addtarget->execute($raid->{id},$1,$2,$3)){ - $error .= "

    Something went wrong: ".$DBH->errstr."

    "; + $error .= "

    Something went wrong when adding $1:$2".($3 ? ":$3" : '').": ".$DBH->errstr."

    "; } } if (param('alliance') =~ /^(\d+)$/ && $1 != 1){ @@ -135,7 +135,24 @@ sub render_body { unless ($DBH->commit){ $error .= "

    Something went wrong: ".$DBH->errstr."

    "; } + }elsif (param('cmd') eq 'targets'){ + $DBH->begin_work; + my $comment = $DBH->prepare(q{UPDATE raid_targets SET comment = ? WHERE id = ?}); + my $unclaim = $DBH->prepare(q{DELETE FROM raid_claims WHERE target = ? AND wave = ?}); + my $block = $DBH->prepare(q{INSERT INTO raid_claims (target,uid,wave) VALUES(?,-2,?)}); + for $_ (param()){ + if (/^comment:(\d+)$/){ + $comment->execute(escapeHTML(param($_)),$1) or $error .= p($DBH->errstr); + }elsif(/^unclaim:(\d+):(\d+)$/){ + $unclaim->execute($1,$2) or $error .= p($DBH->errstr); + log_message $ND::UID,"BC unclaimed target $1 wave $2."; + }elsif(/^block:(\d+):(\d+)$/){ + $block->execute($1,$2) or $error .= p($DBH->errstr); + } + } + $DBH->commit or $error .= p($DBH->errstr); } + } if ($raid && param('removeTarget')){ $error .= "test"; @@ -144,15 +161,6 @@ sub render_body { $error .= "

    Something went wrong: ".$DBH->errstr."

    "; } } - if ($raid && param('block') && param('target')){ - $DBH->do(q{INSERT INTO raid_claims (target,uid,wave) VALUES(?,-2,?)} - ,undef,param('target'),param('block')); - } - if ($raid && param('unclaim') && param('target')){ - $DBH->do(q{DELETE FROM raid_claims WHERE target = ? AND wave = ?} - ,undef,param('target'),param('unclaim')); - log_message $ND::UID,"BC unclaimed target ".param('target')." wave ".param('unclaim')."."; - } my $groups = $DBH->prepare(q{SELECT g.gid,g.groupname,raid FROM groups g LEFT OUTER JOIN (SELECT gid,raid FROM raid_access WHERE raid = ?) AS ra ON g.gid = ra.gid WHERE g.attack}); $groups->execute($raid ? $raid->{id} : undef); @@ -194,7 +202,7 @@ sub render_body { $order = "$1 DESC"; } - my $targetquery = $DBH->prepare(qq{SELECT r.id,coords(x,y,z),raid,comment,size,score,value,race,planet_status AS planetstatus,relationship,comment + my $targetquery = $DBH->prepare(qq{SELECT r.id,coords(x,y,z),raid,comment,size,score,value,race,planet_status AS planetstatus,relationship,comment,r.planet FROM current_planet_stats p JOIN raid_targets r ON p.id = r.planet WHERE r.raid = ? ORDER BY $order}); @@ -219,6 +227,31 @@ sub render_body { push @waves,{Wave => $i, Claimers => $claimers}; } $target->{waves} = \@waves; + + my $scans = $DBH->prepare(q{SELECT DISTINCT ON (type) type, tick, scan FROM scans + WHERE planet = ? AND type ~ 'Unit|Planet|Advanced Unit|.* Analysis' AND tick + 24 > tick() AND scan is not null + GROUP BY type, tick, scan ORDER BY type ,tick DESC}); + $scans->execute($target->{planet}); + delete $target->{planet}; + my %scans; + while (my $scan = $scans->fetchrow_hashref){ + $scans{$scan->{type}} = $scan; + } + + my @scans; + for my $type ('Planet','Unit','Advanced Unit','Surface Analysis','Technology Analysis'){ + next unless exists $scans{$type}; + my $scan = $scans{$type}; + if ($self->{TICK} - $scan->{tick} > 5){ + $scan->{scan} =~ s{}{}; + } + if ($type eq 'Planet'){ + $target->{PlanetScan} = $scan->{scan}; + next; + } + push @scans,{Scan => $scan->{scan}}; + } + $target->{Scans} = \@scans; push @targets,$target; } $BODY->param(Targets => \@targets); diff --git a/templates/editRaid.tmpl b/templates/editRaid.tmpl index 94ed903..6725cd6 100644 --- a/templates/editRaid.tmpl +++ b/templates/editRaid.tmpl @@ -62,6 +62,10 @@ ValueXP

    + + + +
    Target: #
    @@ -78,27 +82,28 @@
    - - - - - - -

    Comment:
    - -
    -

    - -
     
    -

    Unclaim wave ()

    +

    Unclaim wave ():

    -

    Block wave

    +

    Block wave :

    -
     

    Remove

    + +
    +

    Comment:
    + + +

    +
    + +
    + +
    +
    +
    + -- 2.39.2 From d6febe3aa8ee44a6cbc4ff336e9cd60c7a3477ca Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Tue, 13 Mar 2007 11:55:28 +0000 Subject: [PATCH 15/16] minor fix --- templates/editRaid.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/editRaid.tmpl b/templates/editRaid.tmpl index 6725cd6..e0ab28a 100644 --- a/templates/editRaid.tmpl +++ b/templates/editRaid.tmpl @@ -94,8 +94,8 @@

    Comment:
    -

    +
    -- 2.39.2 From 031327dbddb9665e0d5003dbc65d6956da9ea8b1 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Wed, 28 Mar 2007 11:05:27 +0000 Subject: [PATCH 16/16] need to specify which uid, since it's now added to forum_threads too --- ND/Web/Forum.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ND/Web/Forum.pm b/ND/Web/Forum.pm index 6b122c6..cbeb747 100644 --- a/ND/Web/Forum.pm +++ b/ND/Web/Forum.pm @@ -25,8 +25,7 @@ use HTML::Template; use ND::Web::Include; require Exporter; -our @ISA = qw/Exporter/; - +our @ISA = qw/Exporter/; our @EXPORT = qw/viewForumThread addForumPost addForumThread markThreadAsRead/; sub viewForumThread { @@ -38,7 +37,7 @@ sub viewForumThread { $template->param(Post => $thread->{post}); my $posts = $ND::DBH->prepare(q{SELECT u.username,date_trunc('seconds',fp.time::timestamp) AS time,fp.message,COALESCE(fp.time > ftv.time,TRUE) AS unread -FROM forum_threads ft JOIN forum_posts fp USING (ftid) JOIN users u USING (uid) LEFT OUTER JOIN (SELECT * FROM forum_thread_visits WHERE uid = $2) ftv ON ftv.ftid = ft.ftid +FROM forum_threads ft JOIN forum_posts fp USING (ftid) JOIN users u ON u.uid = fp.uid LEFT OUTER JOIN (SELECT * FROM forum_thread_visits WHERE uid = $2) ftv ON ftv.ftid = ft.ftid WHERE ft.ftid = $1 ORDER BY fp.time ASC }); -- 2.39.2