<commit_before><?php

namespace site\controllers;

use Yii;
use yii\web\BadRequestHttpException;
use common\components\Controller;
use yii\filters\VerbFilter;
use common\components\AccessControl;

/**
 * Site controller
 */
class SiteController extends Controller
{
  /**
   * @inheritdoc
   */
  public function behaviors()
  {
    return [
      'access' => [
        'class' => AccessControl::class,
        'rules' => [
          [
            'actions' => ['index', 'blog', 'error', 'privacy', 'terms', 'about', 'captcha', 'contact', 'faq'],
            'allow' => true,
          ],
          [
            'actions' => ['login', 'signup', 'reset-password', 'request-password-reset', 'verify-email'],
            'allow' => true,
            'roles' => ['?'],
          ],
          [
            'actions' => ['logout', 'welcome'],
            'allow' => true,
            'roles' => ['@'],
          ],
        ],
      ],
      'verbs' => [
        'class' => VerbFilter::class,
        'actions' => [
          'logout' => ['post'],
        ],
      ],
    ];
  }

  public function actionIndex()
  {
    return $this->render('index');
  }

  public function actionBlog()
  {
    $time = Yii::$container->get(\common\interfaces\TimeInterface::class); 
    $key = "index_blog_".$time->getLocalDate('UTC');
    $posts = Yii::$app->cache->get($key);
    if($posts === false) {
      $posts = \Yii::$app->getModule('blog')
                            ->fetch()
                            ->parse()
                            ->results;
    }
    Yii::$app->cache->set($key, $posts, 60*60*24);

    return $this->render('blog', ['posts'=>$posts]);
  }

  public function actionLogin()
  {
    $model = Yii::$container->get(\common\models\LoginForm::class);
    if ($model->load(Yii::$app->request->post()) && $model->login()) {
      return $this->goBack();
    } else {
      return $this->render('login', [
        'model' => $model,
      ]);<commit_msg>Don't write to the cache every time! Just when we need to<commit_after><?php

namespace site\controllers;

use Yii;
use yii\web\BadRequestHttpException;
use common\components\Controller;
use yii\filters\VerbFilter;
use common\components\AccessControl;

/**
 * Site controller
 */
class SiteController extends Controller
{
  /**
   * @inheritdoc
   */
  public function behaviors()
  {
    return [
      'access' => [
        'class' => AccessControl::class,
        'rules' => [
          [
            'actions' => ['index', 'blog', 'error', 'privacy', 'terms', 'about', 'captcha', 'contact', 'faq'],
            'allow' => true,
          ],
          [
            'actions' => ['login', 'signup', 'reset-password', 'request-password-reset', 'verify-email'],
            'allow' => true,
            'roles' => ['?'],
          ],
          [
            'actions' => ['logout', 'welcome'],
            'allow' => true,
            'roles' => ['@'],
          ],
        ],
      ],
      'verbs' => [
        'class' => VerbFilter::class,
        'actions' => [
          'logout' => ['post'],
        ],
      ],
    ];
  }

  public function actionIndex()
  {
    return $this->render('index');
  }

  public function actionBlog()
  {
    $time = Yii::$container->get(\common\interfaces\TimeInterface::class); 
    $key = "index_blog_".$time->getLocalDate('UTC');
    $posts = Yii::$app->cache->get($key);
    if($posts === false) {
      $posts = \Yii::$app->getModule('blog')
                            ->fetch()
                            ->parse()
                            ->results;
      Yii::$app->cache->set($key, $posts, 60*60*24);
    }

    return $this->render('blog', ['posts'=>$posts]);
  }

  public function actionLogin()
  {
    $model = Yii::$container->get(\common\models\LoginForm::class);
    if ($model->load(Yii::$app->request->post()) && $model->login()) {
      return $this->goBack();
    } else {
      return $this->render('login', [
        'model' => $model,
      ]);
{'fraction_non_alphanumeric': 0.19828887770508305, 'fraction_numerical': 0.003019627579265224, 'mean_word_length': 2.0068078668683813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, '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': '2959174', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1221, 'n_words': 217}