<commit_before><?php

namespace Warlog\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

use Warlog\Form\WarlogForm;
use Warlog\Model\Warlog;
use Warlog\Model\WarlogTable;
use Account\Model\Role;

use Application\Constants;

class WarlogController extends AbstractActionController
{
    /**
     * @var WarlogTable
     */
    private $warlogTable;

    public function indexAction()
    {
        $warlog = $this->getWarlogTable()->getWarlog();
        if (!$warlog) {
            return new ViewModel([
                'warlog'          => new Warlog(),
                'win_percentage'  => 0,
                'loss_percentage' => 0,
                'draw_percentage' => 0,
            ]);
        }
        $total = $warlog->getWins() + $warlog->getLosses() + $warlog->getDraws();
        return new ViewModel([
            'warlog'          => $warlog,
            'win_percentage'  => $warlog->getWins() / $total * 100,
            'loss_percentage' => $warlog->getLosses() / $total * 100,
            'draw_percentage' => $warlog->getDraws() / $total * 100,
        ]);
    }

    public function uploadAction()
    {
        $session = new \Zend\Session\Container('user');
        if ($session->role < Role::CO) {
            return $this->redirect()->toRoute('account', ['action' => 'noright']);
        }

        $form = new WarlogForm();
        $form->get('submit')->setValue('Upload Warlog');

        $warlog = $this->getWarlogTable()->getWarlog();
        if (!$warlog) {
            $warlog = new Warlog();
        }

        $form->bind($warlog);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $form->setInputFilter($warlog->getInputFilter());
            $post = array_merge_recursive($request->getPost()->toArray(),
                $request->getFiles()->toArray());

            $form->setData($post);
            if ($form->isValid()) {
                $data = $form->getData();
                if (strstr($data->getFile()['type'], 'image')) {<commit_msg>resolve #27<commit_after><?php

namespace Warlog\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

use Warlog\Form\WarlogForm;
use Warlog\Model\Warlog;
use Warlog\Model\WarlogTable;
use Account\Model\Role;

use Application\Constants;

class WarlogController extends AbstractActionController
{
    /**
     * @var WarlogTable
     */
    private $warlogTable;

    public function indexAction()
    {
        $warlog = $this->getWarlogTable()->getWarlog();
        if (!$warlog) {
            return new ViewModel([
                'warlog'          => new Warlog(),
                'win_percentage'  => 0.1,
                'loss_percentage' => 0.1,
                'draw_percentage' => 0.1,
            ]);
        }
        $total           = $warlog->getWins() + $warlog->getLosses() + $warlog->getDraws();
        $win_percentage  = $warlog->getWins() > 0 ? $warlog->getWins() / $total * 100 : 0.1;
        $loss_percentage = $warlog->getLosses() > 0 ? $warlog->getLosses() / $total * 100 : 0.1;
        $draw_percentage = 100 - $win_percentage - $loss_percentage;
        return new ViewModel([
            'warlog'          => $warlog,
            'win_percentage'  => $win_percentage,
            'loss_percentage' => $loss_percentage,
            'draw_percentage' => $draw_percentage,
        ]);
    }

    public function uploadAction()
    {
        $session = new \Zend\Session\Container('user');
        if ($session->role < Role::CO) {
            return $this->redirect()->toRoute('account', ['action' => 'noright']);
        }

        $form = new WarlogForm();
        $form->get('submit')->setValue('Upload Warlog');

        $warlog = $this->getWarlogTable()->getWarlog();
        if (!$warlog) {
            $warlog = new Warlog();
        }

        $form->bind($warlog);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $form->setInputFilter($warlog->getInputFilter());
            $post = array_merge_recursive($request->getPost()->toArray(),
                $request->getFiles()->toArray());

            $form->setData($post);
            if ($form->isValid()) {
                $data = $form->getData();
                if (strstr($data->getFile()['type'], 'image')) {
{'fraction_non_alphanumeric': 0.16459197786998617, 'fraction_numerical': 0.008068234209313048, 'mean_word_length': 2.110394265232975, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 80, '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': '6643879', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1288, 'n_words': 227}