<commit_before><?php

namespace Devlabs\SportifyBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

/**
 * Class ScoresUpdateController
 * @package Devlabs\SportifyBundle\Controller
 */
class ScoresUpdateController extends Controller
{
    /**
     * @Route("/scores/update/all",
     *     name="scores_update_all"
     * )
     */
    public function updateAllAction()
    {
        // if user is not logged in, redirect to login page
        $securityContext = $this->container->get('security.authorization_checker');
        if (!$securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            return $this->redirectToRoute('fos_user_security_login');
        }

        // Get an instance of the Entity Manager
        $em = $this->getDoctrine()->getManager();

        // Get the ScoreUpdater service and update all scores
        $scoresUpdater = $this->get('app.score_updater');
        $scoresUpdater->setEntityManager($em);
        $scoresUpdater->updateAll();

        // redirect to the Home page
        return $this->redirectToRoute('home');
    }

    /**
     * @Route("/scores/update/user-positions-tournament/{tournament_id}",
     *     name="scores_update_user_pos_tournament"
     * )
     */
    public function updateUserPositionsForTournamentAction($tournament_id)
    {
        // if user is not logged in, redirect to login page
        $securityContext = $this->container->get('security.authorization_checker');
        if (!$securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            return $this->redirectToRoute('fos_user_security_login');
        }

        // Get an instance of the Entity Manager
        $em = $this->getDoctrine()->getManager();

        // Get the ScoreUpdater service and update user positions in tournament
        $scoresUpdater = $this->get('app.score_updater');
        $scoresUpdater->setEntityManager($em);
        $scoresUpdater->updateUserPositionsForTournament($tournament_id);

        // redirect to the Home page
        return $this->redirectToRoute('home');
    }
}
<commit_msg>Add slack notification to #sportify channel in ScoresUpdate controller<commit_after><?php

namespace Devlabs\SportifyBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

/**
 * Class ScoresUpdateController
 * @package Devlabs\SportifyBundle\Controller
 */
class ScoresUpdateController extends Controller
{
    /**
     * @Route("/scores/update/all",
     *     name="scores_update_all"
     * )
     */
    public function updateAllAction()
    {
        // if user is not logged in, redirect to login page
        $securityContext = $this->container->get('security.authorization_checker');
        if (!$securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            return $this->redirectToRoute('fos_user_security_login');
        }

        // Get an instance of the Entity Manager
        $em = $this->getDoctrine()->getManager();

        // Get the ScoreUpdater service and update all scores
        $scoresUpdater = $this->get('app.score_updater');
        $scoresUpdater->setEntityManager($em);
        $scoresUpdater->updateAll();

        // creating a Slack object for setting and sending messages
        $slack = $this->get('app.slack');
        $slack->setUrl('<KEY>');
        $slack->setChannel('#sportify');
        $slack->setText('@channel: Match results and standings updated.');
        $slack->post();

        // redirect to the Home page
        return $this->redirectToRoute('home');
    }

    /**
     * @Route("/scores/update/user-positions-tournament/{tournament_id}",
     *     name="scores_update_user_pos_tournament"
     * )
     */
    public function updateUserPositionsForTournamentAction($tournament_id)
    {
        // if user is not logged in, redirect to login page
        $securityContext = $this->container->get('security.authorization_checker');
        if (!$securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            return $this->redirectToRoute('fos_user_security_login');
        }

        // Get an instance of the Entity Manager
        $em = $this->getDoctrine()->getManager();

        // Get the ScoreUpdater service and update user positions in tournament
        $scoresUpdater = $this->get('app.score_updater');
        $scoresUpdater->setEntityManager($em);
        $scoresUpdater->updateUserPositionsForTournament($tournament_id);

        // redirect to the Home page
        return $this->redirectToRoute('home');
    }
}

{'fraction_non_alphanumeric': 0.12121212121212122, 'fraction_numerical': 0.0, 'mean_word_length': 3.043440486533449, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 49, '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': '6963597', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1292, 'n_words': 258}