Sync with --pgweb.
authorSteinar H. Gunderson <sesse@samfundet.no>
Mon, 4 Apr 2005 14:09:32 +0000 (14:09 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Mon, 4 Apr 2005 14:09:32 +0000 (14:09 +0000)
Patches applied:

 * sgunderson@bigfoot.com--2005-private/ccbs--pgweb--1.0--patch-20
   Add a script for showing all players.

html/players.pl [new file with mode: 0755]
html/templates/index.tmpl
html/templates/players.tmpl [new file with mode: 0644]

diff --git a/html/players.pl b/html/players.pl
new file mode 100755 (executable)
index 0000000..8158d4d
--- /dev/null
@@ -0,0 +1,18 @@
+#! /usr/bin/perl
+
+use ccbs;
+use strict;
+use warnings;
+
+my $cgi = new CGI;
+my $id = $cgi->param('id');
+
+my $dbh = ccbs::db_connect();
+
+my $players = ccbs::db_fetch_all($dbh, 'SELECT player,nick,countryname,clubname,count(*) AS num_songs,COUNT(DISTINCT song) AS num_unique_songs,COUNT(DISTINCT tournament) AS num_tournaments,AVG(score)::integer AS avg_score,MAX(score) AS high_score FROM scores NATURAL JOIN players NATURAL JOIN countries NATURAL LEFT JOIN clubs GROUP BY player,nick,countryname,clubname ORDER BY LOWER(nick)');
+
+ccbs::print_header();
+ccbs::process_template('players.tmpl', 'Players', {
+       players => $players,
+});
+$dbh->disconnect;
index 28ec2699080dc4656389516bf90cc844bf78d16b..466c76ec5b42f665943f540edae7fb217a0513ba 100644 (file)
@@ -9,6 +9,7 @@
 <div>
   <ul>
     <li><a href="tournaments.pl">Turneringer</a></li>
+    <li><a href="players.pl">Spillere</a></li>
 [% IF !public %]
     <li><a href="add-tournament.pl">Legg til turnering</a></li>
     <li><a href="randomsongs.pl">Sangvelger</a></li>
diff --git a/html/templates/players.tmpl b/html/templates/players.tmpl
new file mode 100644 (file)
index 0000000..53f8546
--- /dev/null
@@ -0,0 +1,28 @@
+[%# vim:set filetype=html: %]
+
+  <div>
+    <table>
+      <tr>
+        <th>Nick</th>
+        <th>Country</th>
+        <th>Club</th>
+        <th>Participations</th>
+        <th>Songs played</th>
+        <th>Different played</th>
+        <th>High score</th>
+        <th>Average</th>
+      </tr>
+[% FOR p = players %]
+      <tr>
+        <td><a href="player.pl?id=[% p.player %]">[% p.nick %]</a></td>
+        <td>[% p.countryname %]</td>
+        <td>[% p.clubname %]</td>
+        <td>[% p.num_tournaments %]</td>
+        <td>[% p.num_songs %]</td>
+        <td>[% p.num_unique_songs %]</td>
+        <td>[% p.high_score %]</td>
+        <td>[% p.avg_score %]</td>
+      </tr>
+[% END %]
+    </table>
+  </div>