<commit_before><?php

namespace Atotrukis\MainBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;

class CityController extends Controller
{

    // TODO: use this function to get ip address when deployed to server
    // TODO: send to service
    // when in server runs in virtual box this function wont get correct ip
    private function getUserIP()
    {
        $client  = @$_SERVER['HTTP_CLIENT_IP'];
        $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
        $remote  = $_SERVER['REMOTE_ADDR'];

        if (filter_var($client, FILTER_VALIDATE_IP)) {
            $ip = $client;
        } elseif (filter_var($forward, FILTER_VALIDATE_IP)) {
            $ip = $forward;
        } else {
            $ip = $remote;
        }

        return $ip;
    }

    //TODO: throw code to service
    public function setCityAction()
    {
        $cityService = $this->get('cityService');
        $currCity = $cityService->getCity();

        if ($this->container->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) {
            $userCity = $this->get('security.context')->getToken()->getUser()->getCity();
            if ($userCity == null) {
                //set database user city
                $userId = $this->get('security.context')->getToken()->getUser()->getId();
                $cityService->setCity($currCity, $userId);
            }
        } else {
            $cityService->setCityCookie($currCity);<commit_msg>unused funciton deleted<commit_after><?php

namespace Atotrukis\MainBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;

class CityController extends Controller
{

    //TODO: throw code to service
    public function setCityAction()
    {
        $cityService = $this->get('cityService');
        $currCity = $cityService->getCity();

        if ($this->container->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) {
            $userCity = $this->get('security.context')->getToken()->getUser()->getCity();
            if ($userCity == null) {
                //set database user city
                $userId = $this->get('security.context')->getToken()->getUser()->getId();
                $cityService->setCity($currCity, $userId);
            }
        } else {
            $cityService->setCityCookie($currCity);
{'fraction_non_alphanumeric': 0.1396694214876033, 'fraction_numerical': 0.0, 'mean_word_length': 2.6570996978851964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '6811977', 'n_tokens_mistral': 677, 'n_tokens_neox': 667, 'n_words': 134}