1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace VideoGamesRecords\DwhBundle\Manager\Strategy\Table; |
6
|
|
|
|
7
|
|
|
use DateInterval; |
8
|
|
|
use DateTime; |
9
|
|
|
use Exception; |
10
|
|
|
use VideoGamesRecords\DwhBundle\Contracts\Strategy\TableStrategyInterface; |
11
|
|
|
use VideoGamesRecords\DwhBundle\Entity\Player as DwhPlayer; |
12
|
|
|
|
13
|
|
|
class PlayerStrategy extends AbstractTableManager implements TableStrategyInterface |
14
|
|
|
{ |
15
|
|
|
public function supports(string $name): bool |
16
|
|
|
{ |
17
|
|
|
return $name === self::TYPE_PLAYER; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @throws Exception |
23
|
|
|
*/ |
24
|
|
|
public function process(): void |
25
|
|
|
{ |
26
|
|
|
$date1 = new DateTime(); |
27
|
|
|
$date1->sub(new DateInterval('P1D')); |
28
|
|
|
$date2 = new DateTime(); |
29
|
|
|
|
30
|
|
|
$data1 = $this->provider->getNbPostDay($date1, $date2); |
31
|
|
|
$data2 = $this->provider->getDataRank(); |
|
|
|
|
32
|
|
|
$list = $this->provider->getData(); |
33
|
|
|
|
34
|
|
|
foreach ($list as $row) { |
35
|
|
|
$idPlayer = $row['id']; |
36
|
|
|
$dwhPlayer = new DwhPlayer(); |
37
|
|
|
$dwhPlayer->setDate($date1->format('Y-m-d')); |
38
|
|
|
$dwhPlayer->setId($row['id']); |
39
|
|
|
$dwhPlayer->setChartRank0($row['chart_rank0']); |
40
|
|
|
$dwhPlayer->setChartRank1($row['chart_rank1']); |
41
|
|
|
$dwhPlayer->setChartRank2($row['chart_rank2']); |
42
|
|
|
$dwhPlayer->setChartRank3($row['chart_rank3']); |
43
|
|
|
$dwhPlayer->setPointChart($row['point_chart']); |
44
|
|
|
$dwhPlayer->setRankPointChart($row['rank_point_chart']); |
45
|
|
|
$dwhPlayer->setRankMedal($row['rank_medal']); |
46
|
|
|
$dwhPlayer->setNbChart($row['nb_chart']); |
47
|
|
|
$dwhPlayer->setPointGame($row['point_game']); |
48
|
|
|
$dwhPlayer->setRankPointGame($row['rank_point_game']); |
49
|
|
|
$dwhPlayer->setNbPostDay((isset($data1[$idPlayer])) ? $data1[$idPlayer] : 0); |
50
|
|
|
if (isset($data2[$idPlayer])) { |
51
|
|
|
foreach ($data2[$idPlayer] as $key => $value) { |
52
|
|
|
$dwhPlayer->setChartRank($key, $value); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
$this->em->persist($dwhPlayer); |
56
|
|
|
$this->em->flush(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$this->em->flush(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @throws Exception |
64
|
|
|
*/ |
65
|
|
|
public function purge(): void |
66
|
|
|
{ |
67
|
|
|
$date = new DateTime(); |
68
|
|
|
$date = $date->sub(DateInterval::createFromDateString('3 years')); |
69
|
|
|
|
70
|
|
|
//----- delete |
71
|
|
|
$query = $this->em->createQuery('DELETE VideoGamesRecords\DwhBundle\Entity\Player p WHERE p.date < :date'); |
72
|
|
|
$query->setParameter('date', $date->format('Y-m-d')); |
73
|
|
|
$query->execute(); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.