<commit_before><?php

namespace Table\ApiBundle\Controller;

use FOS\RestBundle\Controller\Annotations as Rest;
use Table\MainBundle\Controller\Controller;

use Table\RestaurantBundle\Entity\DTO\ActiveTableOrderDTO;
use Table\RestaurantBundle\Entity\ActiveTableOrder;
use Table\RestaurantBundle\Form\Type\RestActiveTableOrderFormType;
use Table\RestaurantBundle\Entity\ActiveTable;

class ActiveTableOrderController extends Controller
{   
    /**
     * Get Order History
     * 
     * @Rest\View
     */
    public function getOrderHistoryAction()
    {
        $user = $this->get('security.context')->getToken()->getUser(); 
        // user can be anon.
        if ($user == "anon.") {
            return array(
                'success' => false, 
                'errorStr' => $this->get('translator')->trans("validation.errors.user.You should auth at first")
            );
        }
        $orderHistory = $this->getActiveTableOrderManager()->getOrderHistory($user)->getQuery()->getResult();
        
        $response = array();
        foreach ($orderHistory as $order) {
            $dtoOrder = new ActiveTableOrderDTO($order);
            $response[] = $dtoOrder;
        }
   
        return array(
            "success" => true,
            "response" => $response
        );
    }
    
    /**
     * @Rest\View
     */
    public function reserveAction()
    {
        $form = $this->createForm(new RestActiveTableOrderFormType(), new ActiveTableOrder());
        // collect Date Time
        $reserveTime = $this->getRequest()->request->get('reserveTime');
        $reserveDate = $this->getRequest()->request->get('reserveDate');
        // get reserve date and time
        $reserveDateTime = new \DateTime($reserveDate . " " . $reserveTime, new \DateTimeZone(ActiveTableOrder::RESERVE_TIMEZONE));
        
        // init active table
        $activeTable = $this->getActiveTableManager()->findOneById($this->getRequest()->request->get('activeTable'));
        <commit_msg>fix time in table order<commit_after><?php

namespace Table\ApiBundle\Controller;

use FOS\RestBundle\Controller\Annotations as Rest;
use Table\MainBundle\Controller\Controller;

use Table\RestaurantBundle\Entity\DTO\ActiveTableOrderDTO;
use Table\RestaurantBundle\Entity\ActiveTableOrder;
use Table\RestaurantBundle\Form\Type\RestActiveTableOrderFormType;
use Table\RestaurantBundle\Entity\ActiveTable;

class ActiveTableOrderController extends Controller
{   
    /**
     * Get Order History
     * 
     * @Rest\View
     */
    public function getOrderHistoryAction()
    {
        $user = $this->get('security.context')->getToken()->getUser(); 
        // user can be anon.
        if ($user == "anon.") {
            return array(
                'success' => false, 
                'errorStr' => $this->get('translator')->trans("validation.errors.user.You should auth at first")
            );
        }
        $orderHistory = $this->getActiveTableOrderManager()->getOrderHistory($user)->getQuery()->getResult();
        
        $response = array();
        foreach ($orderHistory as $order) {
            $dtoOrder = new ActiveTableOrderDTO($order);
            $response[] = $dtoOrder;
        }
   
        return array(
            "success" => true,
            "response" => $response
        );
    }
    
    /**
     * @Rest\View
     */
    public function reserveAction()
    {
        $form = $this->createForm(new RestActiveTableOrderFormType(), new ActiveTableOrder());
        // collect Date Time
        $reserveTime = $this->getRequest()->request->get('reserveTime');
        $reserveDate = $this->getRequest()->request->get('reserveDate');
        // get reserve date and time
        $reserveDateTime = new \DateTime($reserveDate . " " . $reserveTime);
        
        // init active table
        $activeTable = $this->getActiveTableManager()->findOneById($this->getRequest()->request->get('activeTable'));
        
{'fraction_non_alphanumeric': 0.13600608982491752, 'fraction_numerical': 0.0, 'mean_word_length': 2.532258064516129, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, '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': '3954714', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1063, 'n_words': 198}