<commit_before><?php

namespace LogTrackerBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;

class DefaultController extends Controller
{
    public function indexAction() {
        return $this->render('LogTrackerBundle:Default:index.html.twig', array());
    }

    public function viewAction() {
        return $this->render('LogTrackerBundle:Default:view.html.twig', array());
    }

    public function viewDataErrorAction() {
        $projectHelper = $this->container->get('project_helper');
        $indexer = $this->container->get('core.indexer.solr');
        $data = array('dataset' => array(), 'schema' => array());

        $criteria =
            array('project' => $projectHelper->getProject(), 'domain' => $projectHelper->getDomain(), '+type:error');
        $criteria = array_filter($criteria);
        $results = $indexer->search('asgard_logs', $criteria, 0, 1, array('daemon'));
        foreach ($results->facets['daemon'] as $serverType => $val) {
            $criteriaServerType = array_merge($criteria, array('+daemon' => $serverType));
            $resultsServerType = $indexer->search('asgard_logs', $criteriaServerType, 0, 1, array('type_s'));
            $firstDate = $resultsServerType->results[0]->date;
            $firstDay = date('Y-m-d', strtotime($firstDate));
            foreach ($resultsServerType->facets['type_s'] as $type => $val) {
                $criteriaType = array_merge($criteriaServerType, array('+type_s' => $type));
                $resultsType = $indexer->search('asgard_logs', $criteriaType, 0, 1,
                    array('date' => array('date' => array('start' => $firstDay, 'gap' => '+1DAY'))));
                foreach ($resultsType->facets['date'] as $date => $nb) {
                    if (!array_key_exists($date, $data['dataset'])) {
                        $data['dataset'][$date]["total"] = 0;
                    }
                    $data['schema']["{$serverType} / {$type}"] = $resultsType->query;
                    $data['dataset'][$date]["date"] = substr($date, 0, 10);
                    $data['dataset'][$date]["{$serverType} / {$type}"] = $nb;
                    $data['dataset'][$date]["total"] += $nb;
                }
            }
        }
        ksort($data['dataset']);
        $data['dataset'] = array_values($data['dataset']);

        $response = new JsonResponse();
        $response->setData($data);

        return $response;
    }<commit_msg>Adjust to use name and not label<commit_after><?php

namespace LogTrackerBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;

class DefaultController extends Controller
{
    public function indexAction() {
        return $this->render('LogTrackerBundle:Default:index.html.twig', array());
    }

    public function viewAction() {
        return $this->render('LogTrackerBundle:Default:view.html.twig', array());
    }

    public function viewDataErrorAction() {
        $projectHelper = $this->container->get('project_helper');
        $indexer = $this->container->get('core.indexer.solr');
        $data = array('dataset' => array(), 'schema' => array());

        $criteria = array();
        if ($projectHelper->hasProject()) {
            $criteria['project'] = $projectHelper->getProject()->getName();
        }
        if ($projectHelper->hasDomain()) {
            $criteria['domain'] = $projectHelper->getDomain()->getName();
        }
        $criteria[] = '+type:error';
        $criteria = array_filter($criteria);
        $results = $indexer->search('asgard_logs', $criteria, 0, 1, array('daemon'));
        foreach ($results->facets['daemon'] as $serverType => $val) {
            $criteriaServerType = array_merge($criteria, array('+daemon' => $serverType));
            $resultsServerType = $indexer->search('asgard_logs', $criteriaServerType, 0, 1, array('type_s'));
            $firstDate = $resultsServerType->results[0]->date;
            $firstDay = date('Y-m-d', strtotime($firstDate));
            foreach ($resultsServerType->facets['type_s'] as $type => $val) {
                $criteriaType = array_merge($criteriaServerType, array('+type_s' => $type));
                $resultsType = $indexer->search('asgard_logs', $criteriaType, 0, 1,
                    array('date' => array('date' => array('start' => $firstDay, 'gap' => '+1DAY'))));
                foreach ($resultsType->facets['date'] as $date => $nb) {
                    if (!array_key_exists($date, $data['dataset'])) {
                        $data['dataset'][$date]["total"] = 0;
                    }
                    $data['schema']["{$serverType} / {$type}"] = $resultsType->query;
                    $data['dataset'][$date]["date"] = substr($date, 0, 10);
                    $data['dataset'][$date]["{$serverType} / {$type}"] = $nb;
                    $data['dataset'][$date]["total"] += $nb;
                }
            }
        }
        ksort($data['dataset']);
        $data['dataset'] = array_values($data['dataset']);

        $response = new JsonResponse();
        $response->setData($data);

        return $response;
    }
{'fraction_non_alphanumeric': 0.1819747416762342, 'fraction_numerical': 0.004592422502870264, 'mean_word_length': 2.7070921985815604, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 67, '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': '3310184', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1451, 'n_words': 252}