X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fstats.php;h=c7b0da16c8eb4285469eeceffed21a9383c21299;hp=eac8a8e12a7b06c52a3d37836715565199ccb110;hb=6437c15bdaac379a15d7e6392122f027d8254ec6;hpb=9239ba22c382383cd258ad3f36b2bc0dc99664b2 diff --git a/include/stats.php b/include/stats.php index eac8a8e..c7b0da1 100644 --- a/include/stats.php +++ b/include/stats.php @@ -21,7 +21,7 @@ DB_update_user_timestamp($myid); display_user_menu(); /* start statistics*/ -echo "
These kind of games have been played this often:
";
-$result = DB_query("SELECT COUNT(*) as c,type from Game".
- " WHERE status='gameover'".
- " GROUP BY type".
- " ORDER BY c DESC");
-while( $r = DB_fetch_array($result))
- echo "".$r[1]." (".$r[0].")
";
-echo "
These kind of solos have been played this often:
";
-$result = DB_query("SELECT COUNT(*) as c,solo from Game".
- " WHERE status='gameover'".
- " AND type='solo'".
- " GROUP BY solo".
- " ORDER BY c DESC");
-while( $r = DB_fetch_array($result))
- echo "".$r[1]." (".$r[0].")
";
-echo "
The longest session is session ".$long[1]." with ".$long[0]. " games played by ".join(", ",$names).".
\n"; } + +/* number of solos */ +$result = DB_query_array_all("SELECT type,COUNT(*) as c from Game". + " WHERE status='gameover'". + " GROUP BY type". + " ORDER BY c DESC"); +array_unshift($result,array("Type","Frequency")); +echo output_table($result,"Game types","stats"); + +/* break up solos in types */ +$result = DB_query_array_all("SELECT solo,COUNT(*) as c from Game". + " WHERE status='gameover'". + " AND type='solo'". + " GROUP BY solo". + " ORDER BY c DESC"); +array_unshift($result,array("Type","Frequency")); +echo output_table($result,"Kind of solos","stats"); + +/* + 2 top user mit maximaler quote an solo (min 10 games) + + top scoring game: winning players + + game with the same cards: show 3 at random: + player who won, points, what kind of game + select g1.id, g2.id from game g1 left join game g2 on g1.randomnumbers=g2.randomnumbers where g1.idThese players caught the most foxes per game:
\n";
-$result = DB_query("SELECT COUNT(*) /" .
- " (SELECT COUNT(*) FROM Hand".
- " WHERE user_id=User.id) as c,".
- " fullname".
- " FROM Score".
- " LEFT JOIN User ON User.id=winner_id".
- " WHERE score='fox'".
- " GROUP BY winner_id".
- " ORDER BY c DESC LIMIT 5" );
-while( $r = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
-echo "
These players lost their fox most often per game:
\n";
-$result = DB_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 DESC LIMIT 5" );
-while( $r = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
-echo "
These players lost their fox least often per game:
\n";
-$result = DB_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 = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
-echo "
Which positions at the table make the most tricks:
\n";
-$result = DB_query("SELECT COUNT(*) AS c,winner FROM Trick".
- " GROUP BY winner".
- " ORDER BY winner ASC " );
-$r = DB_fetch_array($result);
-if($r[1]==NULL) /* ongoing games, no winner yet */
- $r = DB_fetch_array($result);
-echo " left ".$r[0]."
\n";
-$r = DB_fetch_array($result);
-echo " top ".$r[0]."
\n";
-$r = DB_fetch_array($result);
-echo " right ".$r[0]."
\n";
-$r = DB_fetch_array($result);
-echo " bottom ".$r[0]."
\n";
-echo "
Most games played on the server:
\n";
-$result = DB_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 = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
-echo "
These players are involved in this many active games:
\n";
-$result = DB_query("SELECT COUNT(*) as c, " .
- " fullname FROM Hand".
+$result = DB_query_array_all("SELECT fullname, COUNT(*) as c " .
+ " 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 = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
-echo "
Points/game (you need at least 10 games to be in this statistic):
\n";
-generate_global_score_table();
-echo "