NEW FEATURE: some more statistics
authorArun Persaud <arun@nubati.net>
Tue, 8 Apr 2008 05:59:23 +0000 (22:59 -0700)
committerArun Persaud <arun@nubati.net>
Tue, 8 Apr 2008 05:59:23 +0000 (22:59 -0700)
list the number of games a user is in at the moment and another list
for the total number of games. Also list people that manage not to lose
their foxes.

Signed-off-by: Arun Persaud <arun@nubati.net>
stats.php

index ec1d9b7f109c267589c7c19ac3b453af21b0baa0..9ecbd94904c80011195850591eedfeb7c4d4ec79 100644 (file)
--- a/stats.php
+++ b/stats.php
@@ -162,7 +162,7 @@ else if( isset($_SESSION["name"]) )
                               " fullname FROM Reminder".
                               " LEFT JOIN User ON User.id=user_id".
                               " GROUP BY user_id".
                               " fullname FROM Reminder".
                               " LEFT JOIN User ON User.id=user_id".
                               " GROUP BY user_id".
-                              " ORDER BY c DESC LIMIT 3" );
+                              " ORDER BY c DESC LIMIT 5" );
         while( $r = mysql_fetch_array($result,MYSQL_NUM))
           echo $r[1]." (".$r[0].") <br />\n";
         echo "</p>\n";
         while( $r = mysql_fetch_array($result,MYSQL_NUM))
           echo $r[1]." (".$r[0].") <br />\n";
         echo "</p>\n";
@@ -196,6 +196,20 @@ else if( isset($_SESSION["name"]) )
           echo $r[1]." (".$r[0].") <br />\n";
         echo "</p>\n";
 
           echo $r[1]." (".$r[0].") <br />\n";
         echo "</p>\n";
 
+        echo "<p>These players lost their fox least often per game:<br />\n";
+        $result = mysql_query("SELECT COUNT(*) /" .
+                              "      (SELECT COUNT(*) FROM Hand".
+                              "       WHERE user_id=User.id) as c,".
+                              " fullname".
+                              " FROM Score".
+                              " LEFT JOIN User ON User.id=looser_id".
+                              " WHERE score='fox'".
+                              " GROUP BY looser_id".
+                              " ORDER BY c ASC LIMIT 5" );
+        while( $r = mysql_fetch_array($result,MYSQL_NUM))
+          echo $r[1]." (".$r[0].") <br />\n";
+        echo "</p>\n";
+
         /* which position wins the most tricks  */
         echo "<p>Which positions at the table make the most tricks:<br />\n";
         $result = mysql_query("SELECT COUNT(*) AS c,winner FROM Trick".
         /* which position wins the most tricks  */
         echo "<p>Which positions at the table make the most tricks:<br />\n";
         $result = mysql_query("SELECT COUNT(*) AS c,winner FROM Trick".
@@ -213,6 +227,31 @@ else if( isset($_SESSION["name"]) )
         echo " bottom ".$r[0]." <br />\n";
         echo "</p>\n";
 
         echo " bottom ".$r[0]." <br />\n";
         echo "</p>\n";
 
+        /* most games */
+        echo "<p>Most games played on the server:<br />\n";
+        $result = mysql_query("SELECT COUNT(*) as c,  " .
+                              " fullname FROM Hand".
+                              " LEFT JOIN User ON User.id=user_id".
+                              " GROUP BY user_id".
+                              " ORDER BY c DESC LIMIT 7" );
+        while( $r = mysql_fetch_array($result,MYSQL_NUM))
+          echo $r[1]." (".$r[0].") <br />\n";
+        echo "</p>\n";
+
+        /* most active games */
+        echo "<p>These players are involved in this many active games:<br />\n";
+        $result = mysql_query("SELECT COUNT(*) as c,  " .
+                              " fullname FROM Hand".
+                              " LEFT JOIN User ON User.id=user_id".
+                              " LEFT JOIN Game ON Game.id=game_id".
+                              " WHERE Game.status<>'gameover'".
+                              " GROUP BY user_id".
+                              " ORDER BY c DESC LIMIT 7" );
+        while( $r = mysql_fetch_array($result,MYSQL_NUM))
+          echo $r[1]." (".$r[0].") <br />\n";
+        echo "</p>\n";
+        
+
         /*
          does the party win more often if they start
 
         /*
          does the party win more often if they start