Changeset 2665


Ignore:
Timestamp:
May 12, 2012, 2:46:44 PM (8 years ago)
Author:
teymour
Message:

Optimisation de Bastien Jaillot <http://bastnic.info/>

Location:
cpc/trunk/project/apps/frontend/modules/parlementaire
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/apps/frontend/modules/parlementaire/actions/actions.class.php

    r2653 r2665  
    161161    $query = Doctrine::getTable('Parlementaire')->createQuery('p');
    162162    $query->orderBy('p.nom_de_famille ASC');
     163    $results = $query->execute();
    163164    $this->parlementaires = array();
    164     foreach ($query->execute() as $depute) {
     165    foreach ($results as $depute) {
    165166      $lettre = $depute->nom_de_famille[0];
    166167      $lettre = preg_replace('/[ÉÉ]/', 'E', $lettre);
     
    168169      else $this->parlementaires[$lettre] = array($depute);
    169170    }
    170     $ctquery = Doctrine_Query::create()
     171    unset($results);
     172    $this->total = Doctrine_Query::create()
    171173      ->from('Parlementaire p')
    172174      ->select('count(distinct p.id) as ct')
    173       ->fetchOne();
    174     $this->total = $ctquery['ct'];
    175     $ctquery = Doctrine_Query::create()
     175      ->execute(array(), Doctrine_Core::HYDRATE_SINGLE_SCALAR);
     176    $this->actifs = Doctrine_Query::create()
    176177      ->from('Parlementaire p')
    177178      ->select('count(distinct p.id) as ct')
    178179      ->where('p.fin_mandat IS NULL')
    179180      ->orWhere('p.fin_mandat < p.debut_mandat')
    180       ->fetchOne();
    181     $this->actifs = $ctquery['ct'];
     181      ->execute(array(), Doctrine_Core::HYDRATE_SINGLE_SCALAR);
    182182  }
    183183
  • cpc/trunk/project/apps/frontend/modules/parlementaire/actions/components.class.php

    r1488 r2665  
    1 <?php 
     1<?php
    22class parlementaireComponents extends sfComponents
    33{
    4   public function executeList() 
     4  public function executeList()
    55  {
    66    $this->parlementaires = $this->parlementairequery
    7       ->select('p.*, i.id, count(i.id) as nb')
     7      ->select('p.nom, p.slug, i.id, count(i.id) as nb')
    88      ->groupBy('p.id')
    99      ->orderBy('nb DESC')
    10       ->execute();
     10      ->fetchArray();
    1111
    1212  }
     
    1616  public function executeDuJour()
    1717  {
    18     $this->parlementaire = Doctrine::getTable('Parlementaire')->createQuery('p')->where('fin_mandat IS NULL')->orderBy('rand()')->fetchOne();
     18    $this->parlementaire = Doctrine::getTable('Parlementaire')->createQuery('p')->where('fin_mandat IS NULL')->orderBy('rand()')->limit(1)->fetchOne();
    1919    return ;
    2020  }
     
    3333    $query->where($likes, $searchs);
    3434    $query->orderBy('p.nom_de_famille ASC');
    35    
     35
    3636    $this->parlementaires = $query->execute();
    37    
     37
    3838    $nb = count($this->parlementaires);
    3939    if ($nb == 0) {
  • cpc/trunk/project/apps/frontend/modules/parlementaire/templates/_table.php

    r2473 r2665  
    2828}
    2929foreach($deputes as $depute) {
     30  $url_depute = url_for('@parlementaire?slug='.$depute->slug);
    3031  $ct++; ?>
    31   <div class="list_dep<?php if (isset($circo) && $depute->fin_mandat == null) echo ' dep_map" id="dep'.preg_replace('/^(\d[\dab])$/', '0\\1', strtolower(Parlementaire::getNumeroDepartement($depute->nom_circo))).'-'.sprintf('%02d', $depute->num_circo); ?>" onclick="document.location='<?php echo url_for('@parlementaire?slug='.$depute->slug); ?>'"><span title="<?php echo $depute->nom.' -- '.$depute->getMoyenStatut(); ?>" class="jstitle phototitle block"><a class="urlphoto" href="<?php echo url_for('@parlementaire?slug='.$depute->slug); ?>"></a>
     32  <div class="list_dep<?php if (isset($circo) && $depute->fin_mandat == null) echo ' dep_map" id="dep'.preg_replace('/^(\d[\dab])$/', '0\\1', strtolower(Parlementaire::getNumeroDepartement($depute->nom_circo))).'-'.sprintf('%02d', $depute->num_circo); ?>" onclick="document.location='<?php echo $url_depute; ?>'"><span title="<?php echo $depute->nom.' -- '.$depute->getMoyenStatut(); ?>" class="jstitle phototitle block"><a class="urlphoto" href="<?php echo $url_depute; ?>"></a>
    3233    <span class="list_nom">
    33       <a href="<?php echo url_for('@parlementaire?slug='.$depute->slug); ?>"><?php echo $depute->getNomPrenom(); ?></a>
     34      <a href="<?php echo $url_depute; ?>"><?php echo $depute->getNomPrenom(); ?></a>
    3435    </span>
    35     <span class="list_right"><a href="<?php echo url_for('@parlementaire?slug='.$depute->slug); //if (!isset($circo)) echo url_for('@list_parlementaires_departement?departement='.$depute->nom_circo); else echo url_for('@parlementaire?slug='.$depute->slug); ?>"><?php
     36    <span class="list_right"><a href="<?php echo $url_depute; //if (!isset($circo)) echo url_for('@list_parlementaires_departement?departement='.$depute->nom_circo); else echo url_for('@parlementaire?slug='.$depute->slug); ?>"><?php
    3637      if (isset($circo)) {
    3738        echo '<span class="list_num_circo">';
     
    4041          $string = $depute->getNumDepartement().'&nbsp;&mdash;&nbsp;'.preg_replace("/nscription/", "", $string);
    4142        echo $string.'</span></a>';
    42       } else echo $depute->nom_circo; 
     43      } else echo $depute->nom_circo;
    4344    ?></a></span><br/>
    4445    <span class="list_left">
    45       <?php echo preg_replace('/\s([A-Z]+)$/', ' <a href="'.url_for('@parlementaire?slug='.$depute->slug).'"><span class="c_'.strtolower($depute->getGroupeAcronyme()).'">'."\\1</span></a>", $depute->getStatut()); ?>
     46      <?php echo preg_replace('/\s([A-Z]+)$/', ' <a href="'.$url_depute.'"><span class="c_'.strtolower($depute->getGroupeAcronyme()).'">'."\\1</span></a>", $depute->getStatut()); ?>
    4647    </span>
    4748    <span class="list_right"><?php
     
    4950        echo "0&nbsp;commentaire";
    5051      else {
    51         echo '<a href="'.url_for('@parlementaire?slug='.$depute->slug).'"><span class="list_com">'.$depute->nb_commentaires.'&nbsp;commentaire';
     52        echo '<a href="'.$url_depute.'"><span class="list_com">'.$depute->nb_commentaires.'&nbsp;commentaire';
    5253        if ($depute->nb_commentaires > 1) echo 's';
    5354        echo '</span></a>';
Note: See TracChangeset for help on using the changeset viewer.