Changeset 2417


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

fix pb memoire sur requetes synthese api

Location:
cpc/trunk/project
Files:
2 edited

Legend:

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

    r2333 r2417  
    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      $depute['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         $depute[$kfinal] = $top[$date][$id][$k]['value'];
     60        $depute[$kfinal] = $top[$id][$k]['value'];
    6161        $this->champs[$kfinal] = 1;
    6262      }
  • cpc/trunk/project/lib/task/topDeputesTask.class.php

    r1787 r2417  
    286286    if (isset($arguments['month']) && preg_match('/(\d{4})-(\d{2})-01/', $arguments['month'], $m)) {
    287287      $this->executeMonth($arguments['month']);
    288       $globale = Doctrine::getTable('VariableGlobale')->findOneByChamp('stats_month_'.$m[1]);
     288      $globale = Doctrine::getTable('VariableGlobale')->findOneByChamp('stats_month_'.$m[1].'_'.$m[2]);
    289289      if (!$globale) {
    290290        $globale = new VariableGlobale();
    291         $globale->champ = 'stats_month_'.$m[1];
    292         $globale->value = serialize(array());
    293       }
    294       $topMonth = unserialize($globale->value);
    295       $topMonth[$m[1].$m[2]] = $this->deputes;
    296       $globale->value = serialize($topMonth);
     291        $globale->champ = 'stats_month_'.$m[1].'_'.$m[2];
     292      }
     293      $globale->value = serialize($this->deputes);
    297294      $globale->save();
    298295      return;
Note: See TracChangeset for help on using the changeset viewer.