Private
Public Access
1
0

chg: usr: re-implement the waiting for opponent dialog - refactor its gfx - & add online user selection dialog #4

This commit is contained in:
2026-04-11 22:20:21 +02:00
parent 6b3e19b063
commit 826690769f
13 changed files with 1540 additions and 277 deletions

View File

@@ -11,6 +11,7 @@
namespace App\Repository;
use App\Entity\PlayedGame;
use DateTime;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@@ -41,4 +42,24 @@ class PlayedGameRepository extends ServiceEntityRepository
{
parent::__construct($registry, PlayedGame::class);
}
public function findWaitingGames(int $limit = 20): array
{
// Any legitimately waiting game was updated within the last 10 minutes.
// Abandoned games are stamped with updated = 2000-01-01, so they fail this filter.
$cutoff = new DateTime('-10 minutes');
return $this->createQueryBuilder('p')
->where('p.resign IS NULL')
->andWhere('p.updated > :cutoff')
->andWhere(
'(p.red IS NOT NULL OR p.redAnon IS NOT NULL) AND (p.blue IS NULL AND p.blueAnon IS NULL)
OR (p.blue IS NOT NULL OR p.blueAnon IS NOT NULL) AND (p.red IS NULL AND p.redAnon IS NULL)'
)
->orderBy('p.updated', 'DESC')
->setParameter('cutoff', $cutoff)
->setMaxResults($limit)
->getQuery()
->getResult();
}
}