X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fbriskin5%2Fstat-day.php;fp=web%2Fbriskin5%2Fstat-day.php;h=4bd60cebd102e1364e596074b0c3b6b37c433928;hb=66eaf1176bb114a40111960b5467201efef2b247;hp=ff991e2219d07b539a9a0cb12d90c0105871b85b;hpb=8d16e0d849f5b04cf58e439934c498a78ea5a1eb;p=brisk.git
diff --git a/web/briskin5/stat-day.php b/web/briskin5/stat-day.php
index ff991e2..4bd60ce 100644
--- a/web/briskin5/stat-day.php
+++ b/web/briskin5/stat-day.php
@@ -269,7 +269,7 @@ function main_pgsql($from, $to)
for ($t = 0 ; $t < $trn_n ; $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 ...
@@ -297,14 +297,22 @@ function main_pgsql($from, $to)
fprintf($fpexp, "
");
$tmt_obj = pg_fetch_object($tmt_pg, $m);
- $usr_sql = sprintf("
+ if ($tmt_obj->minus_one_is_old > -1) { // is new
+ $usr_sql = sprintf("
SELECT u.code AS code, u.login AS login, min(g.tstamp) AS first, max(g.tstamp) AS last, m.tidx AS tidx FROM %sbin5_matches AS m, %sbin5_games AS g, %sbin5_points AS p, %susers AS u, %sbin5_table_orders AS o WHERE m.code = g.mcode AND g.code = p.gcode AND u.code = p.ucode AND m.code = %d AND m.code = o.mcode AND u.code = o.ucode GROUP BY u.code, u.login, m.tidx, o.pos ORDER BY o.pos;", $G_dbpfx, $G_dbpfx, $G_dbpfx, $G_dbpfx, $G_dbpfx, $tmt_obj->code);
+ }
+ else { // is old
+ $usr_sql = sprintf("
+SELECT u.code AS code, u.login AS login, min(g.tstamp) AS first, max(g.tstamp) AS last, m.tidx AS tidx 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 GROUP BY u.code, u.login, m.tidx;", $G_dbpfx, $G_dbpfx, $G_dbpfx, $G_dbpfx, $tmt_obj->code);
+ }
if (($usr_pg = pg_query($bdb->dbconn->db(), $usr_sql)) == FALSE ) {
+ log_crit("stat-day: pg_query usr_sql failed");
break;
}
$usr_n = pg_numrows($usr_pg);
if ($usr_n != BIN5_PLAYERS_N) {
+ log_crit("stat-day: wrong number of players");
break;
}
@@ -341,22 +349,29 @@ SELECT u.code AS code, u.login AS login, min(g.tstamp) AS first, max(g.tstamp) A
if ($u != BIN5_PLAYERS_N) {
break;
}
- fprintf($fpexp, "