diff --git a/Mimir/src/helpers/SessionState.php b/Mimir/src/helpers/SessionState.php index 041d0478..e39ca218 100644 --- a/Mimir/src/helpers/SessionState.php +++ b/Mimir/src/helpers/SessionState.php @@ -167,6 +167,9 @@ public static function fromJson(\Common\Ruleset $rules, array $playersIds, strin $instance = new self($rules, $playersIds); foreach ($ret as $key => $value) { + if ($key === '_isFinished') { // deprecated field, left for compatibility + continue; + } $instance->$key = $value; } diff --git a/Mimir/src/models/Event.php b/Mimir/src/models/Event.php index f52bb8aa..70abaf1e 100644 --- a/Mimir/src/models/Event.php +++ b/Mimir/src/models/Event.php @@ -148,7 +148,7 @@ public function getTablesState($eventId, $omitLastRound = false) SessionPrimitive::STATUS_FINISHED, SessionPrimitive::STATUS_INPROGRESS, SessionPrimitive::STATUS_PREFINISHED - ], 0, intval($tablesCount)); + ], 0, intval($tablesCount), 'end_date'); return $this->_formatTablesState($lastGames, $reggedPlayers, $omitLastRound); } diff --git a/Mimir/src/primitives/PlayerHistory.php b/Mimir/src/primitives/PlayerHistory.php index 31c84e80..69b6e5f7 100644 --- a/Mimir/src/primitives/PlayerHistory.php +++ b/Mimir/src/primitives/PlayerHistory.php @@ -478,7 +478,7 @@ public function getAvgPlace() /** * @param float $startRating - * @param int $penaltyAmount + * @param float $penaltyAmount * @return float */ public function getAvgScore(float $startRating, $penaltyAmount) diff --git a/Mimir/src/primitives/Session.php b/Mimir/src/primitives/Session.php index 406f516a..2f8a94fd 100644 --- a/Mimir/src/primitives/Session.php +++ b/Mimir/src/primitives/Session.php @@ -1032,14 +1032,20 @@ public function rollback(RoundPrimitive $round): void /** * Check if current session is chronologically last for all its players. + * Exclude cancelled games, as they're not counted * @return bool * @throws \Exception */ public function isLastForPlayers() { $last = $this->_ds->table(self::REL_USER) + ->join( + self::$_table, + self::$_table . '.id = ' . self::REL_USER . '.session_id ' . + 'AND ' . self::$_table . ".status != 'cancelled'" + ) ->whereIn('player_id', $this->getPlayersIds()) - ->orderByDesc('id') + ->orderByDesc(self::REL_USER . '.id') ->limit(4) ->findArray();