<commit_before><?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use AppBundle\Entity\User;
use AppBundle\Form\RegisterType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class DefaultController extends Controller
{
    /**
     * @Route("/", name="homepage")
     * @Template()
     */
    public function oktothekAction()
    {
        $em = $this->getDoctrine()->getManager();
        $episode_repo = $em->getRepository('AppBundle:Episode');
        $best_episodes = $episode_repo->findTrendingEpisodes();//findBestEpisodes();
        $newest_episodes = $episode_repo->findNewestEpisodes();
        $newest_playlists = $em->getRepository('AppBundle:Playlist')->findNewestPlaylists();
        return [
            'best_episodes'    => $best_episodes,
            'newest_episodes'  => $newest_episodes,
            'newest_playlists' => $newest_playlists
        ];
    }

    /**
     * @Route("/watch", name="shorturl")
     * @Method("GET")
     */
    public function episodeShortAction(Request $request)
    {
        if ($request->query->get('v')) {
            return $this->redirect($this->generateUrl(
                'oktothek_show_episode',
                ['uniqID' => $request->query->get('v')]
            ));
        } elseif ($request->query->get('s')) {
            return $this->redirect($this->generateUrl(
                'oktothek_show_series',
                ['uniqID' => $request->query->get('s')]
            ));
        } elseif ($request->query->get('p')) {
            return $this->redirect($this->generateUrl(
                'oktothek_show_playlist',
                ['uniqID' => $request->query->get('p')]
            ));
        }
        return $this->redirect('homepage');
    }

    /**
     * @Route("/participate", name="participate")
     * @Template()
     */
    public function participateAction()
    {
        return [];
    }

    /**
     * @Route("/help", name="help")
     * @Template()
     */
    public function helpAction()
    {
        $episode = $this->get('oktolab_media')->getEpisode(
            $this->getParameter('okto_help_uniqID')
        );
        return ['episode' => $episode];
    }

    /**
     * @Route("/imprint", name="imprint")
     * @Template()
     */
    public function imprintAction()
    {
        return [];
    }

    /**
     * @Route("/privacy_policy", name="privacy_policy")
     * @Template()
     */
    public function privacyPolicyAction()
    {
        return [];
    }

    /**
     * @Route("/tos", name="tos")
     * @Template()
     */
    public function tosAction()
    {
        return [];
    }

    /**
     * @Route("/contact", name="contact")
     * @Template()
     */
    public function contactAction()
    {
        return [];
    }

    /**
    * @Route(
    *    "/slider/{number}.{_format}",
    *    name="slider",
    *    requirements={"number": "\d+", "_format": "html|json"},
    *    defaults={"number": 5, "_format": "html"}
    * )
    * @Template()
    */
    public function sliderAction($number = 5)
    {
        $em = $this->getDoctrine()->getManager();
        $slides = $em->getRepository('AppBundle:Slide')->findNewestSlides($number);

        return ['slides' => $slides];
    }

    /**
     * @Route("/register", name="register")
     * @Template()
     */
    public function registerAction(Request $request)
    {
        $user = new User();
        $form = $this->createForm(RegisterType::class, $user);
        $form->add('submit', SubmitType::class, [
            'label' => 'oktothek.register_user_button',
            'attr' => ['class' => 'btn btn-default']
        ]);

        if ($request->getMethod() == "POST") { //sends form
            $form->handleRequest($request);
            if ($form->isValid()) {
                $roles = $this->getParameter('bprs_user.user_defaults');
                $this->get('bprs_user.user')->createUser($user, $roles);
                $this->get('session')->getFlashBag()
                    ->add('success', 'oktothek.success_create_account');

                return $this->redirect($this->generateUrl('homepage'));
            } else {
                $this->get('session')->getFlashBag()
                    ->add('error', 'oktothek.error_create_account');
            }
        }

        return ['form' => $form->createView()];
    }

    public function seriesRedirectAction($webtitle)
    {
        $repo = $this->get('oktolab_media')->getSeriesRepo();
        $series = $repo->findOneBy(['webtitle' => $webtitle]);

        if ($series) {
            return $this->redirect($this->generateUrl(
                'oktothek_show_series', ['uniqID' => $series->getUniqID()]
            ));
        } else {
            $this->get('session')->getFlashBag()->add(
                'info',
                'oktothek.info_webtitle_not_found'
            );
            return $this->redirect($this->generateUrl('homepage'));
        }
    }
}
<commit_msg>now tracking requests for homepage<commit_after><?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use AppBundle\Entity\User;
use AppBundle\Form\RegisterType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class DefaultController extends Controller
{
    /**
     * @Route("/", name="homepage")
     * @Template()
     */
    public function oktothekAction(Request $request)
    {
        $this->get('bprs_analytics')->trackInfo($request, "homepage");
        $em = $this->getDoctrine()->getManager();
        $episode_repo = $em->getRepository('AppBundle:Episode');
        $best_episodes = $episode_repo->findTrendingEpisodes();//findBestEpisodes();
        $newest_episodes = $episode_repo->findNewestEpisodes();
        $newest_playlists = $em->getRepository('AppBundle:Playlist')->findNewestPlaylists();
        return [
            'best_episodes'    => $best_episodes,
            'newest_episodes'  => $newest_episodes,
            'newest_playlists' => $newest_playlists
        ];
    }

    /**
     * @Route("/watch", name="shorturl")
     * @Method("GET")
     */
    public function episodeShortAction(Request $request)
    {
        if ($request->query->get('v')) {
            return $this->redirect($this->generateUrl(
                'oktothek_show_episode',
                ['uniqID' => $request->query->get('v')]
            ));
        } elseif ($request->query->get('s')) {
            return $this->redirect($this->generateUrl(
                'oktothek_show_series',
                ['uniqID' => $request->query->get('s')]
            ));
        } elseif ($request->query->get('p')) {
            return $this->redirect($this->generateUrl(
                'oktothek_show_playlist',
                ['uniqID' => $request->query->get('p')]
            ));
        }
        return $this->redirect('homepage');
    }

    /**
     * @Route("/participate", name="participate")
     * @Template()
     */
    public function participateAction()
    {
        return [];
    }

    /**
     * @Route("/help", name="help")
     * @Template()
     */
    public function helpAction()
    {
        $episode = $this->get('oktolab_media')->getEpisode(
            $this->getParameter('okto_help_uniqID')
        );
        return ['episode' => $episode];
    }

    /**
     * @Route("/imprint", name="imprint")
     * @Template()
     */
    public function imprintAction()
    {
        return [];
    }

    /**
     * @Route("/privacy_policy", name="privacy_policy")
     * @Template()
     */
    public function privacyPolicyAction()
    {
        return [];
    }

    /**
     * @Route("/tos", name="tos")
     * @Template()
     */
    public function tosAction()
    {
        return [];
    }

    /**
     * @Route("/contact", name="contact")
     * @Template()
     */
    public function contactAction()
    {
        return [];
    }

    /**
    * @Route(
    *    "/slider/{number}.{_format}",
    *    name="slider",
    *    requirements={"number": "\d+", "_format": "html|json"},
    *    defaults={"number": 5, "_format": "html"}
    * )
    * @Template()
    */
    public function sliderAction($number = 5)
    {
        $em = $this->getDoctrine()->getManager();
        $slides = $em->getRepository('AppBundle:Slide')->findNewestSlides($number);

        return ['slides' => $slides];
    }

    /**
     * @Route("/register", name="register")
     * @Template()
     */
    public function registerAction(Request $request)
    {
        $user = new User();
        $form = $this->createForm(RegisterType::class, $user);
        $form->add('submit', SubmitType::class, [
            'label' => 'oktothek.register_user_button',
            'attr' => ['class' => 'btn btn-default']
        ]);

        if ($request->getMethod() == "POST") { //sends form
            $form->handleRequest($request);
            if ($form->isValid()) {
                $roles = $this->getParameter('bprs_user.user_defaults');
                $this->get('bprs_user.user')->createUser($user, $roles);
                $this->get('session')->getFlashBag()
                    ->add('success', 'oktothek.success_create_account');

                return $this->redirect($this->generateUrl('homepage'));
            } else {
                $this->get('session')->getFlashBag()
                    ->add('error', 'oktothek.error_create_account');
            }
        }

        return ['form' => $form->createView()];
    }

    public function seriesRedirectAction($webtitle)
    {
        $repo = $this->get('oktolab_media')->getSeriesRepo();
        $series = $repo->findOneBy(['webtitle' => $webtitle]);

        if ($series) {
            return $this->redirect($this->generateUrl(
                'oktothek_show_series', ['uniqID' => $series->getUniqID()]
            ));
        } else {
            $this->get('session')->getFlashBag()->add(
                'info',
                'oktothek.info_webtitle_not_found'
            );
            return $this->redirect($this->generateUrl('homepage'));
        }
    }
}

{'fraction_non_alphanumeric': 0.17386772787568694, 'fraction_numerical': 0.00037900322152738296, 'mean_word_length': 2.188821752265861, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 155, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6193876', 'n_tokens_mistral': 3203, 'n_tokens_neox': 3125, 'n_words': 431}