Changeset 2416


Ignore:
Timestamp:
Oct 29, 2011, 4:31:24 PM (9 years ago)
Author:
komodo
Message:

fix pb memoire sur requetes synthese api

Location:
cpc/branches/senat/project
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpc/branches/senat/project/apps/frontend/modules/api/actions/actions.class.php

    r2334 r2416  
    4040  {
    4141    $date = $request->getParameter('date');
    42     $this->forward404Unless(preg_match('/(\d{2,4})-?\d{2}/', $date, $d));
     42    $this->forward404Unless(preg_match('/(\d{2,4})-?(\d{2})/', $date, $d));
    4343    $date = preg_replace('/-/', '', $date);
    4444    $date = preg_replace('/^(\d{2})(\d{2})$/', '20\\1\\2', $date);
    4545    $d[1] = preg_replace('/^(\d{2})$/', '20\\1', $d[1]);
    46     $vg = Doctrine::getTable('VariableGlobale')->findOneByChamp('stats_month_'.$d[1]);
     46    $vg = Doctrine::getTable('VariableGlobale')->findOneByChamp('stats_month_'.$d[1].'_'.$d[2]);
    4747    $top = unserialize($vg->value);
    4848
    49     $this->forward404Unless(isset($top[$date]));
     49    $this->forward404Unless($top);
    5050
    5151    $this->res = array();
    5252    $this->champs = array();
    53     foreach(array_keys($top[$date]) as $id) {
     53    foreach(array_keys($top) as $id) {
    5454      $senateur['id'] = $id;
    5555      $this->champs['id'] = 1;
    5656
    57       foreach (array_keys($top[$date][$id]) as $k) {
     57      foreach (array_keys($top[$id]) as $k) {
    5858        //Gestion de l'ordre des parametres
    5959        $kfinal = preg_replace('/^\d*_/', '', $k);
    60         $senateur[$kfinal] = $top[$date][$id][$k]['value'];
     60        $senateur[$kfinal] = $top[$id][$k]['value'];
    6161        $this->champs[$kfinal] = 1;
    6262      }
  • cpc/branches/senat/project/bin/update_tops.sh

    r2029 r2416  
    44
    55php symfony top:Senateurs
    6 for month in 06 07 08 09 10 11 12; do
    7   php symfony top:Senateurs 2007-$month-01
     6for month in 10 11 12; do
     7  php symfony top:Senateurs 2004-$month-01
    88done
    9 for year in 2008 2009 2010 2011 2012; do
     9for year in 2005 2006 2007 2008 2009 2010 2011 2012; do
    1010  if test $year -gt `date +%Y`; then
    1111    break
  • cpc/branches/senat/project/lib/task/topSenateursTask.class.php

    r2342 r2416  
    319319    if (isset($arguments['month']) && preg_match('/(\d{4})-(\d{2})-01/', $arguments['month'], $m)) {
    320320      $this->executeMonth($arguments['month']);
    321       $globale = Doctrine::getTable('VariableGlobale')->findOneByChamp('stats_month_'.$m[1]);
     321      $globale = Doctrine::getTable('VariableGlobale')->findOneByChamp('stats_month_'.$m[1].'_'.$m[2]);
    322322      if (!$globale) {
    323323        $globale = new VariableGlobale();
    324         $globale->champ = 'stats_month_'.$m[1];
    325         $globale->value = serialize(array());
    326       }
    327       $topMonth = unserialize($globale->value);
    328       $topMonth[$m[1].$m[2]] = $this->senateurs;
    329       $globale->value = serialize($topMonth);
     324        $globale->champ = 'stats_month_'.$m[1].'_'.$m[2];
     325      }
     326      $globale->value = serialize($this->senateurs);
    330327      $globale->save();
    331328      return;
Note: See TracChangeset for help on using the changeset viewer.