<commit_before><?php

/**
 * rate actions.
 *
 * @package    cpc
 * @subpackage rate
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class rateActions extends sfActions
{

  static $rate_conversion = array('0' => 0, '1' => 1, '2' => 2);
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeRateIt(sfWebRequest $request)
  {
    if (!$this->getUser()->isAuthenticated()) {
      $this->getUser()->setFlash('notice', 'Vous devez être identifié pour donner une opinion sur cet élement');
      return $this->redirect($request->getReferer());
    }
    $citoyen_id = $this->getUser()->getAttribute('user_id');
    $note = $request->getParameter('rate');
    $id = $request->getParameter('object_id');
    $type = $request->getParameter('object_type');
    $object = Doctrine::getTable($type)->find($id);
    $this->forward404Unless($object);
    
    $rate = new Rate();
    $rate->rate = self::$rate_conversion[$note];
    $rate->object_type = $object;
    $rate->object_id = $id;
    $rate->citoyen_id = $citoyen_id;
    try {
      $rate->save();
    }catch(Exception $e) {
      $this->getUser()->setFlash('error', 'Vous ne pouvez donner votre avis qu\'une seule fois');
      return $this->redirect($request->getReferer());
    }

    $a = Doctrine_Query::create()
      ->from('Rate')
      ->select('AVG(rate) as rate')
      ->where('object_type = ?', $type)
      ->andWhere('object_id = ?', $id)
      ->fetchArray();

    $object->rate = $a[0]['rate'];
    $object->save();

    $this->getUser()->setFlash('notice', 'Merci ! Votre opinion a bien été prise en compte');
    return $this->redirect($request->getReferer());<commit_msg>fix 500 encountered by google bot's crawls<commit_after><?php

/**
 * rate actions.
 *
 * @package    cpc
 * @subpackage rate
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class rateActions extends sfActions
{

  static $rate_conversion = array('0' => 0, '1' => 1, '2' => 2);
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeRateIt(sfWebRequest $request)
  {
    $this->forward404Unless($request->getReferer());
    if (!$this->getUser()->isAuthenticated()) {
      $this->getUser()->setFlash('notice', 'Vous devez être identifié pour donner une opinion sur cet élement');
      return $this->redirect($request->getReferer());
    }
    $citoyen_id = $this->getUser()->getAttribute('user_id');
    $note = $request->getParameter('rate');
    $id = $request->getParameter('object_id');
    $type = $request->getParameter('object_type');
    $object = Doctrine::getTable($type)->find($id);
    $this->forward404Unless($object);

    $rate = new Rate();
    $rate->rate = self::$rate_conversion[$note];
    $rate->object_type = $object;
    $rate->object_id = $id;
    $rate->citoyen_id = $citoyen_id;
    try {
      $rate->save();
    }catch(Exception $e) {
      $this->getUser()->setFlash('error', 'Vous ne pouvez donner votre avis qu\'une seule fois');
      return $this->redirect($request->getReferer());
    }

    $a = Doctrine_Query::create()
      ->from('Rate')
      ->select('AVG(rate) as rate')
      ->where('object_type = ?', $type)
      ->andWhere('object_id = ?', $id)
      ->fetchArray();

    $object->rate = $a[0]['rate'];
    $object->save();

    $this->getUser()->setFlash('notice', 'Merci ! Votre opinion a bien été prise en compte');
    return $this->redirect($request->getReferer());
{'fraction_non_alphanumeric': 0.18867924528301888, 'fraction_numerical': 0.017758046614872364, 'mean_word_length': 3.517543859649123, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 77, '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': '2762757', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1194, 'n_words': 254}