<commit_before><?php
namespace GifFight\Controller;

use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class GifController
{
    public function removeAction(Request $request, Application $app)
    {
    	$predis = $app['predis'];
    	$id = $request->get('id');
    	if (empty($id)) {
    		return $app->redirect('/?error=invalid-id'); //TODO Use url generator
    	}

    	$gif = json_decode($predis->get('info:' . $id), true);

    	if ($gif['twitter_screen_name'] != $app['session']->get('twitter_screen_name')
    		&& $app['session']->get('twitter_screen_name') != 'ashleyhindle') {
    		return $app->redirect('/?error=dont-own'); //TODO Use url generator
    	}

    	$predis->lrem(date('Y-m-d', $gif['added']), 1, $id);

    	return $app->redirect('/?removed');
    }

    public function upvoteAction(Request $request, Application $app)
    {
    	$predis = $app['predis'];
    	$aid = $request->get('id');

    	if(empty($app['session']->get('twitter_screen_name'))) {
    		return $app->redirect('/?login-to-vote');
    	}

    	if (in_array($app['session']->get('twitter_screen_name'), $predis->lrange('votes:' . $aid, 0, 10000))) {
    		return $app->redirect('/?cheating-pipe-smuggler');
    	}

    	$predis->incr('score:' . $aid);
    	$predis->lpush('votes:' . $aid, [ $app['session']->get('twitter_screen_name') ]);
    	
    	return $app->redirect('/?voted');
    }

    public function downvoteAction(Request $request, Application $app)
    {
    	$predis = $app['predis'];
    	$aid = $request->get('id');
<commit_msg>Awesome changes<commit_after><?php
namespace GifFight\Controller;

use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class GifController
{
    public function removeAction(Request $request, Application $app)
    {
    	$predis = $app['predis'];
    	$id = $request->get('id');
    	if (empty($id)) {
    		return $app->redirect('/?error=invalid-id'); //TODO Use url generator
    	}

    	$gif = json_decode($predis->get('info:' . $id), true);

    	if ($gif['twitter_screen_name'] != $app['session']->get('twitter_screen_name')
    		&& $app['session']->get('twitter_screen_name') != 'ashleyhindle') {
    		return $app->redirect('/?error=dont-own'); //TODO Use url generator
    	}

    	$predis->lrem(date('Y-m-d', $gif['added']), 1, $id);

    	return $app->redirect('/?removed');
    }

    public function upvoteAction(Request $request, Application $app)
    {
    	$predis = $app['predis'];
    	$aid = $request->get('id');

    	if(empty($app['session']->get('twitter_screen_name'))) {
    		return $app->redirect('/twitter');
    	}

    	if (in_array($app['session']->get('twitter_screen_name'), $predis->lrange('votes:' . $aid, 0, 10000))) {
    		return $app->redirect('/?cheating-pipe-smuggler');
    	}

    	$predis->incr('score:' . $aid);
    	$predis->lpush('votes:' . $aid, [ $app['session']->get('twitter_screen_name') ]);
    	
    	return $app->redirect('/?voted');
    }

    public function downvoteAction(Request $request, Application $app)
    {
    	$predis = $app['predis'];
    	$aid = $request->get('id');

{'fraction_non_alphanumeric': 0.20473667809286383, 'fraction_numerical': 0.004362729822374571, 'mean_word_length': 3.638728323699422, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '4811701', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1117, 'n_words': 177}