<commit_before><?php

namespace Intracto\SecretSantaBundle\Service;

use Doctrine\Common\Cache\CacheProvider;
use Intracto\SecretSantaBundle\Model\AnalyticsOptions;
use Intracto\SecretSantaBundle\Service\Analytics\GApi;

class ReportingService
{
    private $cache;
    private $doctrine;
    private $ga_email;
    private $ga_password;
    private $ga_profile_id;

    public function __construct(CacheProvider $cache, $doctrine, $ga_email, $ga_password, $ga_profile_id)
    {
        $this->cache = $cache;
        $this->doctrine = $doctrine;
        $this->ga_email = $ga_email;
        $this->ga_password = $<PASSWORD>;
        $this->ga_profile_id = $ga_profile_id;
    }

    public function getPools()
    {
        if ($this->cache->contains('report_pools')) {
            return unserialize($this->cache->fetch('report_pools'));
        }

        $dbal = $this->doctrine->getConnection();

        $pools = $dbal->fetchAll('
            SELECT count(*) created, date(sentdate) sentdate
            FROM Pool
            WHERE sentdate is not null
            GROUP BY date(sentdate)
            ORDER BY date(sentdate)
        ');

        $this->cache->save('report_pools', serialize($pools), 3600);

        return $pools;
    }

    public function getAnalytics(AnalyticsOptions $options)
    {
        $cachingId = $options->uniqueCachingString();
        if ($this->cache->contains($cachingId)) {
            return unserialize($this->cache->fetch($cachingId));
        }

        $ga = new GApi(
            $this->ga_email,
            $this->ga_password
        );

        $ga->requestReportData(
            $this->ga_profile_id,
            $options->getDimensions(),
            $options->getMetrics(),<commit_msg>Append null pools (cheating ;-)<commit_after><?php

namespace Intracto\SecretSantaBundle\Service;

use Doctrine\Common\Cache\CacheProvider;
use Intracto\SecretSantaBundle\Model\AnalyticsOptions;
use Intracto\SecretSantaBundle\Service\Analytics\GApi;

class ReportingService
{
    private $cache;
    private $doctrine;
    private $ga_email;
    private $ga_password;
    private $ga_profile_id;

    public function __construct(CacheProvider $cache, $doctrine, $ga_email, $ga_password, $ga_profile_id)
    {
        $this->cache = $cache;
        $this->doctrine = $doctrine;
        $this->ga_email = $ga_email;
        $this->ga_password = $<PASSWORD>;
        $this->ga_profile_id = $ga_profile_id;
    }

    public function getPools()
    {
        if ($this->cache->contains('report_pools')) {
            return unserialize($this->cache->fetch('report_pools'));
        }

        $dbal = $this->doctrine->getConnection();

        $pools = $dbal->fetchAll('
            SELECT count(*) created, ifnull(date(sentdate), now()) sentdate
            FROM Pool
            GROUP BY date(sentdate)
            ORDER BY date(sentdate)
        ');

        $this->cache->save('report_pools', serialize($pools), 3600);

        return $pools;
    }

    public function getAnalytics(AnalyticsOptions $options)
    {
        $cachingId = $options->uniqueCachingString();
        if ($this->cache->contains($cachingId)) {
            return unserialize($this->cache->fetch($cachingId));
        }

        $ga = new GApi(
            $this->ga_email,
            $this->ga_password
        );

        $ga->requestReportData(
            $this->ga_profile_id,
            $options->getDimensions(),
            $options->getMetrics(),
{'fraction_non_alphanumeric': 0.12939481268011527, 'fraction_numerical': 0.0023054755043227667, 'mean_word_length': 2.498991935483871, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6645239', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1024, 'n_words': 183}