Total Complexity | 3 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class DownloadRepository extends DocumentRepository |
||
9 | { |
||
10 | public function getProviderStats(Provider $provider, $version = null) |
||
11 | { |
||
12 | $builder = $this->createAggregationBuilder(); |
||
13 | $builder |
||
14 | ->addFields() |
||
15 | ->field('stringdate') |
||
16 | ->dateToString('%Y-%m-%d', '$date') |
||
17 | ->match() |
||
18 | ->field('provider') |
||
19 | ->equals($provider->getName()) |
||
20 | ->sort('date', -1); |
||
21 | |||
22 | if ($version) { |
||
23 | $builder->match() |
||
24 | ->field('version') |
||
25 | ->equals($version); |
||
26 | } |
||
27 | |||
28 | $builder |
||
29 | ->group() |
||
30 | ->field('id') |
||
31 | ->expression('$stringdate') |
||
32 | ->field('downloads') |
||
33 | ->sum(1) |
||
34 | |||
35 | ->project() |
||
36 | ->excludeFields(['_id']) |
||
37 | ->includeFields(['date', 'downloads']) |
||
38 | ->field('date') |
||
39 | ->expression('$_id'); |
||
40 | |||
41 | return $builder->execute(); |
||
42 | } |
||
43 | |||
44 | public function countLast7Days() |
||
53 | } |
||
54 | } |
||
55 |