<commit_before><?php

namespace Bundles\WidgetBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class DefaultController extends Controller
{
    /**
     * Generate images by current settings
     *
     * @param int $userId id of the user
     * @param int $width width of the image
     * @param int $height height of the image
     * @param string $bgColor background color
     * @param string $textColor text color
     *
     * @Route(
     *      "/get-rate/{userId}/{width}/{height}/{bgColor}/{textColor}",
     *      requirements={
     *          "userId": "([0-9]{1,3})",
     *          "width": "([0-9]{1,3})",
     *          "height": "([0-9]{1,3})",
     *          "bgColor": "[0-9a-fA-F]+",
     *          "textColor": "[0-9a-fA-F]+",
     *      }
     * )
     *
     * @return Response
     */
    public function indexAction($userId, $width, $height, $bgColor, $textColor)
    {
        $str = $this->get('image.manager')->getWidgetImage($userId, $width, $height, $bgColor, $textColor);

        if ($str) {
            $headers = array(
                'Content-Type'        => 'image/png',
                'Content-Disposition' => 'inline; filename="image.png"'
            );

            $statusCode = Response::HTTP_OK;
        } else {
            $str = '<html><body><h2>Current user cannot be found or inactive</h2></body></html>';
            $headers = array('Content-Type' => 'text/html');
            $statusCode = Response::HTTP_BAD_REQUEST;<commit_msg>Updated controller for getting user by hash<commit_after><?php

namespace Bundles\WidgetBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Bundles\WidgetBundle\Entity\Users;

class DefaultController extends Controller
{
    /**
     * Generate images by current settings
     *
     * @param int $hash id of the user
     * @param int $width width of the image
     * @param int $height height of the image
     * @param string $bgColor background color
     * @param string $textColor text color
     *
     * @Route(
     *      "/get-rate/{hash}/{width}/{height}/{bgColor}/{textColor}",
     *      requirements={
     *          "hash": "([0-9]{1,3})",
     *          "width": "([0-9]{1,3})",
     *          "height": "([0-9]{1,3})",
     *          "bgColor": "[0-9a-fA-F]+",
     *          "textColor": "[0-9a-fA-F]+",
     *      }
     * )
     *
     * @return Response
     */
    public function indexAction($hash, $width, $height, $bgColor, $textColor)
    {
        /**
         * Get current user by hash
         */
        $user = $this->getDoctrine()->getRepository('WidgetBundle:Users')->findOneBy([
            'hash' => $hash,
            'status' => Users::STATUS_ACTIVE
        ]);

        if ($user) {
            $str = $this->get('image.manager')->getWidgetImage($hash, $width, $height, $bgColor, $textColor);

            $headers = array(
                'Content-Type'        => 'image/png',
                'Content-Disposition' => 'inline; filename="image.png"'
            );

            $statusCode = Response::HTTP_OK;
        } else {
            $str = '<html><body><h2>Current user cannot be found or inactive</h2></body></html>';
            $headers = array('Content-Type' => 'text/html');
            $statusCode = Response::HTTP_BAD_REQUEST;
{'fraction_non_alphanumeric': 0.15696409140369968, 'fraction_numerical': 0.009793253536452665, 'mean_word_length': 2.288908765652952, 'pattern_counts': {'":': 10, '<': 17, '<?xml version=': 0, '>': 30, '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': '6099602', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1089, 'n_words': 228}