Completed
Push — 1.4 ( 6a61c0...59673b )
by Paweł
15s
created

getCountForArticleInternalPageViews()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Analytics Bundle.
7
 *
8
 * Copyright 2018 Sourcefabric z.ú. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2018 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\AnalyticsBundle\Repository;
18
19
use SWP\Bundle\AnalyticsBundle\Model\ArticleEventInterface;
20
use SWP\Bundle\ContentBundle\Model\ArticleInterface;
21
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository;
22
23
class ArticleEventRepository extends EntityRepository implements ArticleEventRepositoryInterface
24
{
25 View Code Duplication
    public function getCountForArticleInternalPageViews(ArticleInterface $article): int
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        $qb = $this->createQueryBuilder('ae')
28
            ->select('COUNT(ae.id)')
29
            ->andWhere('ae.action = :action')
30
            ->andWhere('ae.pageViewSource = :pageviewSource')
31
            ->leftJoin('ae.articleStatistics', 'ast')
32
            ->andWhere('ast.article = :article')
33
            ->setParameters([
34
                'article' => $article,
35
                'action' => ArticleEventInterface::ACTION_PAGEVIEW,
36
                'pageviewSource' => ArticleEventInterface::PAGEVIEW_SOURCE_INTERNAL,
37
            ]);
38
39
        return (int) $qb->getQuery()->getSingleScalarResult();
40
    }
41
42 View Code Duplication
    public function getCountForArticleAllPageViews(ArticleInterface $article): int
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $qb = $this->createQueryBuilder('ae')
45
            ->select('COUNT(ae.id)')
46
            ->andWhere('ae.action = :action')
47
            ->leftJoin('ae.articleStatistics', 'ast')
48
            ->andWhere('ast.article = :article')
49
            ->setParameters([
50
                'article' => $article,
51
                'action' => ArticleEventInterface::ACTION_PAGEVIEW,
52
            ]);
53
54
        return (int) $qb->getQuery()->getSingleScalarResult();
55
    }
56
57 View Code Duplication
    public function getCountForArticleAllImpressions(ArticleInterface $article): int
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    {
59
        $qb = $this->createQueryBuilder('ae')
60
            ->select('COUNT(ae.id)')
61
            ->andWhere('ae.action = :action')
62
            ->leftJoin('ae.articleStatistics', 'ast')
63
            ->andWhere('ast.article = :article')
64
            ->setParameters([
65
                'article' => $article,
66
                'action' => ArticleEventInterface::ACTION_IMPRESSION,
67
            ]);
68
69
        return (int) $qb->getQuery()->getSingleScalarResult();
70
    }
71
}
72