X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Fbriskin5%2Fstat-day.php;h=d96cb6c626dadada6e43d88911c631ea704fcac4;hb=302c97f7ac81dfcc6fc8d8d44359f4f432e4618a;hp=16781204e621f647da8a7adf3f97aae95f7d006d;hpb=7d6de01c21200b7283b6dd5ba1a39a3a2741ad54;p=brisk.git
diff --git a/web/briskin5/stat-day.php b/web/briskin5/stat-day.php
index 1678120..d96cb6c 100644
--- a/web/briskin5/stat-day.php
+++ b/web/briskin5/stat-day.php
@@ -43,7 +43,10 @@ $G_base = "../";
$mlang_stat_day = array( 'normal match'=> array( 'it' => 'Partite normali',
'en' => 'Normal matches' ),
'special match' => array( 'it' => 'Partite speciali',
- 'en' => 'Special matches')
+ 'en' => 'Special matches'),
+
+ 'info_total'=> array( 'it' => 'totali',
+ 'en' => 'En totali')
);
@@ -138,7 +141,7 @@ function main_file($curtime)
for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
// echo $p." i) ".$i."
";
$username = $ar[9+($i*2)];
- if (($item = $bdb->getitem_bylogin($username, &$id)) == FALSE) {
+ if (($item = $bdb->getitem_bylogin($username, $id)) == FALSE) {
echo "WARNING: the user [".$username."] NOT EXISTS!
";
continue;
}
@@ -235,6 +238,7 @@ function main_pgsql($from, $to)
$ret = FALSE;
$fpexp = FALSE;
+ // log_crit("stat-day: BEGIN");
do {
if (($fpexp = @fopen(LEGAL_PATH."/explain.log", 'w')) == FALSE) {
log_crit("stat-day: open explain failed");
@@ -263,10 +267,18 @@ function main_pgsql($from, $to)
$trn_n = pg_numrows($trn_pg);
printf("Number of tournaments: %d\n", $trn_n);
+ // loop on tournaments
for ($t = 0 ; $t < $trn_n ; $t++) {
+ // log_crit("stat-day: LOOP t");
$trn_obj = pg_fetch_object($trn_pg, $t);
- $tmt_sql = sprintf("SELECT m.code AS code FROM %sbin5_matches AS m, %sbin5_games AS g, %sbin5_tournaments as t WHERE t.code = m.tcode AND m.code = g.mcode AND t.code = %d AND g.tstamp >= '%s' AND g.tstamp < '%s' GROUP BY m.code;",
+ $tmt_sql = sprintf("
+SELECT m.code AS code, m.mazzo_next as minus_one_is_old
+ FROM %sbin5_matches AS m, %sbin5_games AS g, %sbin5_tournaments as t
+ WHERE t.code = m.tcode AND m.code = g.mcode
+ AND t.code = %d AND g.tstamp >= '%s' AND g.tstamp < '%s'
+ GROUP BY m.code, minus_one_is_old
+ ORDER BY m.code, minus_one_is_old DESC;",
$G_dbpfx, $G_dbpfx, $G_dbpfx, $trn_obj->code, $from, $to);
// if deletable old matches exists then ...
@@ -290,40 +302,48 @@ function main_pgsql($from, $to)
printf("[Tournament [%s]], number of matches: %d\n", $mlang_stat_day[$trn_obj->name][$G_lang], $tmt_n);
fprintf($fpexp, "
%s | ", $usr_obj[$u]->login); - $pts_sql = sprintf("SELECT p.pts as pts from %sbin5_matches as m, %sbin5_games as g, %sbin5_points as p, %susers as u WHERE m.code = g.mcode AND g.code = p.gcode AND u.code = p.ucode AND m.code = %d AND u.code = %d ORDER BY g.code", $G_dbpfx, $G_dbpfx, $G_dbpfx, $G_dbpfx, - $tmt_obj->code, $usr_obj[$u]->code); + fprintf($fpexp, "%s | ", $users[$u]['login']); + // note: we are looping on users, order on them not needed + $pts_sql = sprintf(" +SELECT p.pts AS pts + FROM %sbin5_games AS g, %sbin5_points AS p + WHERE g.code = p.gcode AND g.mcode = %d AND p.ucode = %d + ORDER BY g.tstamp", + $G_dbpfx, $G_dbpfx, + $tmt_obj->code, $users[$u]['code']); // points of the match for each user - if (($pts_pg[$u] = pg_query($bdb->dbconn->db(), $pts_sql)) == FALSE) { + if (($pts_pg[$u] = pg_query($bdb->dbconn->db(), $pts_sql)) == FALSE) { + log_crit("stat-day: pts_sql failed"); break; } if ($u == 0) { @@ -331,52 +351,128 @@ SELECT u.code AS code, u.login AS login, min(g.tstamp) AS first, max(g.tstamp) A } else { if ($num_games != pg_numrows($pts_pg[$u])) { + log_crit("stat-day: num_games != pg_numrows"); break; } } } if ($u != BIN5_PLAYERS_N) { + log_crit("stat-day: u != BIN5_PLAYERS_N"); break; } - fprintf($fpexp, "mazzo | descrizione | mazzo | descrizione | \n"); + } // LISTA DELLE VARIE PARTITE + $pts_obj = array(); for ($g = 0 ; $g < $num_games ; $g++) { $gam_obj = pg_fetch_object($gam_pg, $g); fprintf($fpexp, "
---|---|---|---|---|
%d | ", $pts_obj->pts); + $pts = $pts_obj[$u]->pts; + + if ($pts == 0) + $cla_nam = 'bg_white'; + else if ($pts == $pt_min) + $cla_nam = 'bg_red'; + else if ($pts == $pt_max) + $cla_nam = 'bg_green'; + else if ($pts < 0) + $cla_nam = 'bg_lired'; + else if ($pts > 0) + $cla_nam = 'bg_ligre'; + + fprintf($fpexp, "<%s class='%s'>%d%s>", + ($tmt_obj->minus_one_is_old == -1 ? "td" : "th"), + $cla_nam, pow(2,$gam_obj->mult) * $pts, + ($tmt_obj->minus_one_is_old == -1 ? "td" : "th")); + } + if ($tmt_obj->minus_one_is_old != -1) { + fprintf($fpexp, "%s | %s | ", $users[$gam_obj->mazzo]['login'], + xcape( game_description($gam_obj->act, 'plain', $gam_obj->mult, + $gam_obj->asta_win, + ($gam_obj->asta_win != -1 ? + $users[$gam_obj->asta_win]['login'] : ""), + $gam_obj->friend, + ($gam_obj->friend != -1 ? + $users[$gam_obj->friend]['login'] : ""), + $gam_obj->pnt, $gam_obj->asta_pnt) ) + ); } - fprintf($fpexp, "%s | %s | ", $usr_obj[$gam_obj->mazzo]->login, - xcape( game_description($gam_obj->act, 'plain', $gam_obj->mult, - $gam_obj->asta_win, $usr_obj[$gam_obj->asta_win]->login, - $gam_obj->friend, $usr_obj[$gam_obj->friend]->login, - $gam_obj->pnt, $gam_obj->asta_pnt) ) - ); fprintf($fpexp, "
%d | ", $tot_obj->pts); } - fprintf($fpexp, "%s | \n", $mlang_stat_day['info_total'][$G_lang]); + } fprintf($fpexp, "