|
@@ 202-238 (lines=37) @@
|
| 199 |
|
} |
| 200 |
|
|
| 201 |
|
break; |
| 202 |
|
case 'hour': |
| 203 |
|
$occurrences = $this->getInstantWinOccurrenceMapper()->findBy(array('instantwin' => $game)); |
| 204 |
|
$nbExistingOccurrences = count($occurrences); |
| 205 |
|
$nbOccurencesToCreate = 0; |
| 206 |
|
$nbInterval = (int) ($dateInterval/60); |
| 207 |
|
|
| 208 |
|
// If a hour don't last 60min, I consider it as a hour anyway. |
| 209 |
|
if ($dateInterval%60 > 0) { |
| 210 |
|
++$nbInterval; |
| 211 |
|
} |
| 212 |
|
if ($nbInterval > 0) { |
| 213 |
|
$nbOccurencesToCreate = $game->getOccurrenceNumber() - floor($nbExistingOccurrences/$nbInterval); |
| 214 |
|
} |
| 215 |
|
|
| 216 |
|
$beginningDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y H:i:s')); |
| 217 |
|
$endDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y H'). ':59:59'); |
| 218 |
|
|
| 219 |
|
if ($nbOccurencesToCreate > 0) { |
| 220 |
|
for ($d=1; $d<=$nbInterval; $d++) { |
| 221 |
|
for ($i=1; $i<=$nbOccurencesToCreate; $i++) { |
| 222 |
|
$randomDate = $this->getRandomDate($beginningDrawDate->format('U'), $endDrawDate->format('U')); |
| 223 |
|
$randomDate = \DateTime::createFromFormat('Y-m-d H:i:s', $randomDate); |
| 224 |
|
$occurrence = new \PlaygroundGame\Entity\InstantWinOccurrence(); |
| 225 |
|
$occurrence->setInstantwin($game); |
| 226 |
|
|
| 227 |
|
$occurrence->setValue($randomDate->format('Y-m-d H:i:s')); |
| 228 |
|
$occurrence->setActive(1); |
| 229 |
|
|
| 230 |
|
$this->getInstantWinOccurrenceMapper()->insert($occurrence); |
| 231 |
|
} |
| 232 |
|
$beginningDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginningDrawDate->format('m/d/Y H'). ':00:00'); |
| 233 |
|
$beginningDrawDate->add(new \DateInterval('PT1H')); |
| 234 |
|
$endDrawDate->add(new \DateInterval('PT1H')); |
| 235 |
|
} |
| 236 |
|
} |
| 237 |
|
|
| 238 |
|
break; |
| 239 |
|
case 'day': |
| 240 |
|
$occurrences = $this->getInstantWinOccurrenceMapper()->findBy(array('instantwin' => $game)); |
| 241 |
|
$nbExistingOccurrences = count($occurrences); |
|
@@ 239-278 (lines=40) @@
|
| 236 |
|
} |
| 237 |
|
|
| 238 |
|
break; |
| 239 |
|
case 'day': |
| 240 |
|
$occurrences = $this->getInstantWinOccurrenceMapper()->findBy(array('instantwin' => $game)); |
| 241 |
|
$nbExistingOccurrences = count($occurrences); |
| 242 |
|
$nbOccurencesToCreate = 0; |
| 243 |
|
$nbInterval = (int) ($dateInterval/(60*24)); |
| 244 |
|
|
| 245 |
|
// Prise en compte des changements d'horaires |
| 246 |
|
// If a day don't last 24h, I consider it as a day anyway |
| 247 |
|
|
| 248 |
|
if ($dateInterval%(60*24) > 0) { |
| 249 |
|
++$nbInterval; |
| 250 |
|
} |
| 251 |
|
|
| 252 |
|
if ($nbInterval > 0) { |
| 253 |
|
$nbOccurencesToCreate = $game->getOccurrenceNumber() - floor($nbExistingOccurrences/$nbInterval); |
| 254 |
|
} |
| 255 |
|
|
| 256 |
|
$beginningDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y H:i:s')); |
| 257 |
|
$endDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y'). ' 23:59:59'); |
| 258 |
|
if ($nbOccurencesToCreate > 0) { |
| 259 |
|
for ($d=1; $d<=$nbInterval; $d++) { |
| 260 |
|
for ($i=1; $i<=$nbOccurencesToCreate; $i++) { |
| 261 |
|
$randomDate = $this->getRandomDate($beginningDrawDate->format('U'), $endDrawDate->format('U')); |
| 262 |
|
$randomDate = \DateTime::createFromFormat('Y-m-d H:i:s', $randomDate); |
| 263 |
|
$occurrence = new \PlaygroundGame\Entity\InstantWinOccurrence(); |
| 264 |
|
$occurrence->setInstantwin($game); |
| 265 |
|
$occurrence->setValue($randomDate->format('Y-m-d H:i:s')); |
| 266 |
|
$occurrence->setActive(1); |
| 267 |
|
|
| 268 |
|
$this->getInstantWinOccurrenceMapper()->insert($occurrence); |
| 269 |
|
} |
| 270 |
|
// As the first beginning date was not @ midnight, |
| 271 |
|
// I recreate the beginning date |
| 272 |
|
$beginningDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginningDrawDate->format('m/d/Y'). ' 00:00:00'); |
| 273 |
|
$beginningDrawDate->add(new \DateInterval('P1D')); |
| 274 |
|
$endDrawDate->add(new \DateInterval('P1D')); |
| 275 |
|
} |
| 276 |
|
} |
| 277 |
|
|
| 278 |
|
break; |
| 279 |
|
case 'week': |
| 280 |
|
// Rechercher tous les IG non gagnés pour chaque jour puis soustrais à ceux à créer |
| 281 |
|
$occurences = $this->getInstantWinOccurrenceMapper()->findBy(array('instantwin' => $game)); |