<commit_before><?php

namespace AppBundle\Controller;

use AppBundle\Entity as EntityDir;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;

/**
 * @Route("/pa")
 */
class PaController extends AbstractController
{
    /**
     * @Route("/", name="pa_dashboard")
     * @Template
     */
    public function indexAction(Request $request)
    {
        /* @var $clients EntityDir\Client[] */
        $endpoint = '/client/get-all?' . http_build_query([
//            'user_id' => $this->getUser()->getId(),
            'q'       => '123 sdf',
            'page'    => 1,
            'status'  => '*', // starte
            'exclude_submitted'  => true,
        ]);

        $clients = $this->getRestClient()->get($endpoint, 'Client[]', ['client', 'report', 'status']);

        // the view needs reports data, so easier to re-organize by reports
        // note: for PA (so far), one client only has one report. And there are no clients without report\
        /* @var $reports EntityDir\Report\Report[] */
        $reports = [];
        foreach ($clients as $client) {
            $report = $client->getReports()[0]; // no reason why data is wrong
            $report->setClient($client);
            $reports[] = $report;
        }

        // calculate count
        $statesCount = ['total'=>0,'notStarted' => 0, 'readyToSubmit' => 0, 'notFinished' => 0];
        foreach($reports as $report) {
            $statesCount[$report->getStatus()->getStatus()]++;
            $statesCount['total']++;
        }<commit_msg>order reports by end_date ASC<commit_after><?php

namespace AppBundle\Controller;

use AppBundle\Entity as EntityDir;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;

/**
 * @Route("/pa")
 */
class PaController extends AbstractController
{
    /**
     * @Route("/", name="pa_dashboard")
     * @Template
     */
    public function indexAction(Request $request)
    {
        /* @var $clients EntityDir\Client[] */
        $endpoint = '/client/get-all?' . http_build_query([
//            'user_id' => $this->getUser()->getId(),
            'q'       => '123 sdf',
            'page'    => 1,
            'status'  => '*', // starte
            'exclude_submitted'  => true,
            'sort'  => 'end_date',
            'sort_direction'  => 'asc',
        ]);

        $clients = $this->getRestClient()->get($endpoint, 'Client[]', ['client', 'report', 'status']);

        // the view needs reports data, so easier to re-organize by reports
        // note: for PA (so far), one client only has one report. And there are no clients without report\
        /* @var $reports EntityDir\Report\Report[] */
        $reports = [];
        foreach ($clients as $client) {
            $report = $client->getReports()[0]; // no reason why data is wrong
            $report->setClient($client);
            $reports[] = $report;
        }

        // calculate count
        $statesCount = ['total'=>0,'notStarted' => 0, 'readyToSubmit' => 0, 'notFinished' => 0];
        foreach($reports as $report) {
            $statesCount[$report->getStatus()->getStatus()]++;
            $statesCount['total']++;
        }
{'fraction_non_alphanumeric': 0.16245165129425765, 'fraction_numerical': 0.005355548943766736, 'mean_word_length': 2.3721163490471415, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '2481491', 'n_tokens_mistral': 970, 'n_tokens_neox': 947, 'n_words': 228}