コード例 #1
0
 public function set(Stats $stats)
 {
     $builder = $this->gameRepository->createQueryBuilder('game');
     $builder->select('COUNT(game.id)');
     $builder->where('game.date > :hours');
     $builder->setParameter(':hours', new \DateTime('-24 hours'), Type::DATETIME);
     $result = $builder->getQuery()->getSingleScalarResult();
     $stat = new Stat('Games last 24H', $result);
     $stats->addStat($stat);
 }
コード例 #2
0
 public function set(Stats $stats)
 {
     $builder = $this->gameRepository->createQueryBuilder('game');
     $builder->select('COUNT(game.id)');
     $builder->where($builder->expr()->eq('game.wintype', 2));
     $result = $builder->getQuery()->getSingleScalarResult();
     if ($result == 0) {
         $stat = new Stat('Total backgammons', $result, 0);
     } else {
         $stat = new Stat('Total backgammons', $result, round($result / $this->totalGames() * 100, 2));
     }
     $stats->addStat($stat);
 }
コード例 #3
0
 public function set(Stats $stats)
 {
     $stat = new Stat('Total games played', $this->totalGames());
     $stats->addStat($stat);
 }