File size: 1,064 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<?php

namespace MauticPlugin\MauticSocialBundle\Entity;

use Mautic\CoreBundle\Entity\CommonRepository;
use Mautic\CoreBundle\Helper\Chart\ChartQuery;

/**
 * @extends CommonRepository<PostCount>
 */
class PostCountRepository extends CommonRepository
{
    /**
     * Fetch Lead stats for some period of time.
     *
     * @param array $options
     *
     * @return PostCount[]
     *
     * @throws \Doctrine\ORM\NoResultException
     * @throws \Doctrine\ORM\NonUniqueResultException
     */
    public function getLeadStatsPost($dateFrom, $dateTo, $options): array
    {
        $chartQuery = new ChartQuery($this->getEntityManager()->getConnection(), $dateFrom, $dateTo);

        // Load points for selected periods
        $q = $chartQuery->prepareTimeDataQuery(MAUTIC_TABLE_PREFIX.'monitor_post_count', 'post_date', $options, 'post_count', 'sum');
        if (isset($options['monitor_id'])) {
            $q->andwhere($q->expr()->eq('t.monitor_id', (int) $options['monitor_id']));
        }

        return $chartQuery->loadAndBuildTimeData($q);
    }
}