]> ruin.nu Git - ndwebbie.git/commitdiff
Support fractional def points.
authorMichael Andreen <harv@ruin.nu>
Sat, 13 Sep 2008 09:46:08 +0000 (11:46 +0200)
committerMichael Andreen <harv@ruin.nu>
Sat, 13 Sep 2008 09:46:08 +0000 (11:46 +0200)
Also, use numeric type for other points for compatibility.

database/fractional_points.sql [new file with mode: 0644]
lib/NDWeb/Controller/Members.pm
root/src/members/points.tt2

diff --git a/database/fractional_points.sql b/database/fractional_points.sql
new file mode 100644 (file)
index 0000000..6c9b489
--- /dev/null
@@ -0,0 +1,5 @@
+ALTER TABLE users ALTER COLUMN defense_points TYPE NUMERIC(4,1);
+ALTER TABLE users ALTER COLUMN attack_points TYPE NUMERIC(3,0);
+UPDATE users set humor_points = -100 where humor_points < -100;
+ALTER TABLE users ALTER COLUMN humor_points TYPE NUMERIC(3,0);
+ALTER TABLE users ALTER COLUMN scan_points TYPE NUMERIC(5,0);
index bb31b694b6484b96cdca34a533bf148eb4ed5b13..4e57477ef07f362308222869ec3894dd3e4078a2 100644 (file)
@@ -32,7 +32,7 @@ sub index : Path : Args(0) {
        $c->stash(comma => \&comma_value);
        $c->stash(u => $dbh->selectrow_hashref(q{SELECT planet,defense_points
                        ,attack_points,scan_points,humor_points
-                       , (attack_points+defense_points+scan_points/20) as total_points
+                       , (attack_points+defense_points+scan_points/20)::NUMERIC(5,1) as total_points
                        , sms,rank,hostmask FROM users WHERE uid = ?
                        },undef,$c->user->id)
        );
@@ -285,7 +285,7 @@ sub points : Local {
 
        my $query = $dbh->prepare(qq{SELECT username,defense_points,attack_points
                ,scan_points,humor_points
-               ,(attack_points+defense_points+scan_points/20) as total_points
+               ,(attack_points+defense_points+scan_points/20)::NUMERIC(4,0) as total_points
                , count(NULLIF(rc.launched,FALSE)) AS raid_points
                FROM users u LEFT OUTER JOIN raid_claims rc USING (uid)
                WHERE uid IN (SELECT uid FROM groupmembers WHERE gid = 2)
index 01c9ff5a94fcb62a87ae8f785e463d4ce7f44ceb..a90a8e38468f75deddc4d0afc762baec6a069e4f 100644 (file)
@@ -10,8 +10,8 @@
        <th><a href="[% c.uri_for('points','humor_points') %]">Humor</a></th>
        </tr>
 [% FOR m IN members %]
-       <tr class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
-       <td>[% m.username %]</td>
+       <tr align="right" class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
+       <td align="left">[% m.username %]</td>
        <td>[% m.total_points %]</td>
        <td>[% m.defense_points %]</td>
        <td>[% m.attack_points %]</td>