TableQuery.php
1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace FootyRoom\Queries;
use FootyRoom\Support\MongoClient;
class TableQuery
{
/**
* @var \FootyRoom\Support\MongoClient
*/
protected $mongo;
/**
* Constructor.
*
* @param \FootyRoom\Support\MongoClient $mongo
*/
public function __construct(MongoClient $mongo)
{
$this->mongo = $mongo->footyroom;
}
/**
* Returns raw tables data queried by list of Enetpulse stage ids.
*
* @param int[] $enetStageIds
*
* @return array[]
*/
public function findByEnetStageIds($enetStageIds)
{
$options = [
'projection' => [
'_id' => 0,
'enetStageId' => 1,
'conference' => 1,
'spots' => 1,
'participants.name' => 1,
'participants.teamId' => 1,
'participants.rank' => 1,
'participants.form' => 1,
'participants.next' => 1,
'participants.data.wins.value' => 1,
'participants.data.draws.value' => 1,
'participants.data.defeats.value' => 1,
'participants.data.goalsagainst.value' => 1,
'participants.data.goalsfor.value' => 1,
'participants.data.played.value' => 1,
'participants.data.points.value' => 1,
'participants.data.rank.value' => 1,
'participants.data.currentRound' => 1,
'participants.data.previousRound' => 1,
],
];
return $this->mongo->tables->find(
[
'enetStageId' => ['$in' => $enetStageIds],
'participants' => [
'$exists' => '1', '$not' => ['$size' => 0],
],
],
$options
);
}
}