<commit_before><?php

namespace Kitpages\ShopBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Kitpages\ShopBundle\Model\Paginator;
use Kitpages\ShopBundle\Entity\Order;
use Kitpages\ShopBundle\Entity\OrderHistory;
use Kitpages\ShopBundle\Entity\OrderUser;

class StatisticsController extends Controller
{
    /**
     * display the admin navigation
     * @param none
     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
     */
    public function indexAction()
    {

        $request = $this->get('request');
        // build basic form
        $builder = $this->createFormBuilder(null);
        $builder->add(
            'date',
            'date',
            array(
                'input'  => 'timestamp',
                'widget' => 'choice',
                'data' => time(),
                'format' => 'YYYY-MMMM-dd',
            )
        );
        // get form
        $form = $builder->getForm();

        $date = new \DateTime();

        $year = $date->format('Y');
        $month = $date->format('m');

        $request = $this->get('request');
        if ($request->getMethod() == 'POST') {
             $form->bindRequest($request);

             if ($form->isValid()) {
                 $dataForm = $request->request->get('form');
                 $year = $dataForm['date']['year'];
                 $month = $dataForm['date']['month'];
             }
        }


        $statisticsManager = $this->get('kitpages_shop.statisticsManager');

        /************************************
        ********** sales per month **********
        *************************************/
        $dateStart = new \DateTime("$year-01-01 00:00:00");
        $dateEnd = new \DateTime("$year-01-01 00:00:00");
        $dateEnd = $dateEnd->add(\DateInterval::createFromDateString('1 year'));

        for($i=1; $i<=12; $i++) {
            $dataStatisticList['salesPerMonth'][$i] = 0;
        }

        $querySelect = array(
            'orderPriceWithoutVatTotal' => 'orderPriceWithoutVatTotal'
        );

        $queryWhere = array(
            'stateDateStart' => $dateStart,
            'stateDateEnd' => $dateEnd
        );
        $queryGroupBy = array(
            'stateDate' => '%Y-%m'
        );
        $queryOrderBy = array(
            'stateDate' => 'ASC'
        );

        $dataStatisticSalesPerMonth = $statisticsManager->sales($querySelect, $queryWhere, $queryGroupBy, $queryOrderBy);
        foreach($dataStatisticSalesPerMonth as $data) {
            $dataDate = new \DateTime($data['stateDate']);
            $dataStatisticList['salesPerMonth'][$dataDate->format('n')] = $data['orderPriceWithoutVatTotal'];
        }

        /************************************
        **** sales per day for one month ****
        *************************************/
        $dateStart = new \DateTime("$year-$month-01 00:00:00");
        $dateEnd = new \DateTime("$year-$month-01 00:00:00");
        $dateEnd = $dateEnd->add(\DateInterval::createFromDateString('1 month'));
        for($i=1; $i<=intval(date("t",$dateStart->getTimestamp())); $i++) {
            $dataStatisticList['salesPerDay'][$i] = 0;
        }

        $querySelect = array(
            'orderPriceWithoutVatTotal' => 'orderPriceWithoutVatTotal'
        );
        $queryWhere = array(
            'stateDateStart' => $dateStart,
            'stateDateEnd' => $dateEnd
        );
        $queryGroupBy = array(
            'stateDate' => '%Y-%m-%d'
        );
        $queryOrderBy = array(
            'stateDate' => 'ASC'
        );

        $dataStatisticSalesPerDay = $statisticsManager->sales($querySelect, $queryWhere, $queryGroupBy, $queryOrderBy);

        foreach($dataStatisticSalesPerDay as $data) {
            $dataDate = new \DateTime($data['stateDate']);
            $dataStatisticList['salesPerDay'][$dataDate->format('d')] = $data['orderPriceWithoutVatTotal'];
        }

        /************************************
        *** top ten products of the month ***
        *************************************/
        $dateStart = new \DateTime("$year-$month-01 00:00:00");
        $dateEnd = new \DateTime("$year-$month-01 00:00:00");
        $dateEnd = $dateEnd->add(\DateInterval::createFromDateString('1 month'));
        $dataStatisticList['salesTopTen'] = array();

        $querySelect = array(
            'orderLinePriceWithoutVatTotal' => 'orderLinePriceWithoutVatTotal',
            'shopName' => 'shopName',
            'shopReferenceQantity' => 'shopReferenceQantity'
        );
        $queryWhere = array(
            'stateDateStart' => $dateStart,
            'stateDateEnd' => $dateEnd<commit_msg>modif Day of the month without leading zeros<commit_after><?php

namespace Kitpages\ShopBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Kitpages\ShopBundle\Model\Paginator;
use Kitpages\ShopBundle\Entity\Order;
use Kitpages\ShopBundle\Entity\OrderHistory;
use Kitpages\ShopBundle\Entity\OrderUser;

class StatisticsController extends Controller
{
    /**
     * display the admin navigation
     * @param none
     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
     */
    public function indexAction()
    {

        $request = $this->get('request');
        // build basic form
        $builder = $this->createFormBuilder(null);
        $builder->add(
            'date',
            'date',
            array(
                'input'  => 'timestamp',
                'widget' => 'choice',
                'data' => time(),
                'format' => 'YYYY-MMMM-dd',
            )
        );
        // get form
        $form = $builder->getForm();

        $date = new \DateTime();

        $year = $date->format('Y');
        $month = $date->format('m');

        $request = $this->get('request');
        if ($request->getMethod() == 'POST') {
             $form->bindRequest($request);

             if ($form->isValid()) {
                 $dataForm = $request->request->get('form');
                 $year = $dataForm['date']['year'];
                 $month = $dataForm['date']['month'];
             }
        }


        $statisticsManager = $this->get('kitpages_shop.statisticsManager');

        /************************************
        ********** sales per month **********
        *************************************/
        $dateStart = new \DateTime("$year-01-01 00:00:00");
        $dateEnd = new \DateTime("$year-01-01 00:00:00");
        $dateEnd = $dateEnd->add(\DateInterval::createFromDateString('1 year'));

        for($i=1; $i<=12; $i++) {
            $dataStatisticList['salesPerMonth'][$i] = 0;
        }

        $querySelect = array(
            'orderPriceWithoutVatTotal' => 'orderPriceWithoutVatTotal'
        );

        $queryWhere = array(
            'stateDateStart' => $dateStart,
            'stateDateEnd' => $dateEnd
        );
        $queryGroupBy = array(
            'stateDate' => '%Y-%m'
        );
        $queryOrderBy = array(
            'stateDate' => 'ASC'
        );

        $dataStatisticSalesPerMonth = $statisticsManager->sales($querySelect, $queryWhere, $queryGroupBy, $queryOrderBy);
        foreach($dataStatisticSalesPerMonth as $data) {
            $dataDate = new \DateTime($data['stateDate']);
            $dataStatisticList['salesPerMonth'][$dataDate->format('n')] = $data['orderPriceWithoutVatTotal'];
        }

        /************************************
        **** sales per day for one month ****
        *************************************/
        $dateStart = new \DateTime("$year-$month-01 00:00:00");
        $dateEnd = new \DateTime("$year-$month-01 00:00:00");
        $dateEnd = $dateEnd->add(\DateInterval::createFromDateString('1 month'));
        for($i=1; $i<=intval(date("t",$dateStart->getTimestamp())); $i++) {
            $dataStatisticList['salesPerDay'][$i] = 0;
        }

        $querySelect = array(
            'orderPriceWithoutVatTotal' => 'orderPriceWithoutVatTotal'
        );
        $queryWhere = array(
            'stateDateStart' => $dateStart,
            'stateDateEnd' => $dateEnd
        );
        $queryGroupBy = array(
            'stateDate' => '%Y-%m-%d'
        );
        $queryOrderBy = array(
            'stateDate' => 'ASC'
        );

        $dataStatisticSalesPerDay = $statisticsManager->sales($querySelect, $queryWhere, $queryGroupBy, $queryOrderBy);

        foreach($dataStatisticSalesPerDay as $data) {
            $dataDate = new \DateTime($data['stateDate']);
            $dataStatisticList['salesPerDay'][$dataDate->format('j')] = $data['orderPriceWithoutVatTotal'];
        }

        /************************************
        *** top ten products of the month ***
        *************************************/
        $dateStart = new \DateTime("$year-$month-01 00:00:00");
        $dateEnd = new \DateTime("$year-$month-01 00:00:00");
        $dateEnd = $dateEnd->add(\DateInterval::createFromDateString('1 month'));
        $dataStatisticList['salesTopTen'] = array();

        $querySelect = array(
            'orderLinePriceWithoutVatTotal' => 'orderLinePriceWithoutVatTotal',
            'shopName' => 'shopName',
            'shopReferenceQantity' => 'shopReferenceQantity'
        );
        $queryWhere = array(
            'stateDateStart' => $dateStart,
            'stateDateEnd' => $dateEnd
{'fraction_non_alphanumeric': 0.20044780893485445, 'fraction_numerical': 0.01300778334577247, 'mean_word_length': 2.3357041251778092, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 83, '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': '954831', 'n_tokens_mistral': 2716, 'n_tokens_neox': 2592, 'n_words': 426}