NEW FEATURE: statistics of most solos per game
[e-DoKo.git] / include / stats.php
index 1f4bca947f1b76ee1312788451d6f723fdefbd54..c7b0da16c8eb4285469eeceffed21a9383c21299 100644 (file)
@@ -68,7 +68,7 @@ if($r)
   {
     $long  = DB_fetch_array($r);
     $names = DB_get_all_names_by_gameid($long[2]);
-    echo "The longest session is session ".$long[1]." with ".$long[0].
+    echo "<p>The longest session is session ".$long[1]." with ".$long[0].
       " games played by ".join(", ",$names).".</p>\n";
   }
 
@@ -177,6 +177,20 @@ $result = DB_query_array_all("SELECT fullname, COUNT(*) as c  " .
 array_unshift($result,array("Name","Number of games"));
 echo output_table($result,"Most games","stats");
 
+/* most solos */
+$result = DB_query_array_all("SELECT fullname as fname,".
+                            "       COUNT(*), ".
+                            "       COUNT(*)/(SELECT COUNT(*) FROM Hand LEFT JOIN User ON User.id=Hand.user_id WHERE fullname=fname) as c ".
+                            " FROM Game ".
+                            " LEFT JOIN Hand ON Hand.position=startplayer AND Game.id=Hand.game_id ".
+                            " LEFT JOIN User ON User.id=Hand.user_id ".
+                            " WHERE type='solo' AND Game.solo<>'silent' AND Game.status='gameover' ".
+                            " GROUP BY user_id ".
+                            " ORDER BY c DESC;");
+array_unshift($result,array("Name","Number of solos","Solos/game"));
+echo output_table($result,"Most solos","stats");
+
+
 /* most active games */
 $result = DB_query_array_all("SELECT fullname, COUNT(*) as c  " .
                   " FROM Hand".