Ignore:
Timestamp:
Sep 5, 2012, 4:15:54 PM (12 years ago)
Author:
grum
Message:

version 0.1.0b

. Fix install bugs
. Manage anonymous directories
. Manage CSV export options settings
. Fix IPadress<=>country association bug & improve join performances
. Fix bug on IP filter
. Improve performances for history consult

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/EStat/lib/statDBMonth.class.inc.php

    r17737 r17758  
    7878   *
    7979   * missing values are set to default value
     80   * country is defined automatically after buildIPCountry call; set to '' while
     81   * call is not made
    8082   *
    8183   * @param Array $log : a record
     
    109111      // insert log
    110112      $sql="INSERT INTO logs
    111             (date, IPadress, userId, catId, imageId, tagsId, section,
     113            (date, IPadress, country, userId, catId, imageId, tagsId, section,
    112114             userAgent, uaBrowser, uaBrowserVersion, uaEngine, uaEngineVersion,
    113115             uaOS, uaOSVersion, uaType, screenSizeW, screenSizeH)
     
    115117                      //"'".$this->dbHandle->escapeString($value['IPadress'])."', ".
    116118                      ":IP, ".
     119                      "'', ".
    117120                      $value['userId'].", ".
    118121                      $value['catId'].", ".
     
    254257    if(!isset($filter['uaType'])) $filter['uaType']=null;
    255258
     259    $filter['IPadress']=$this->checkIPFilter($filter['IPadress']);
    256260    // check filter values - getOperator check and 'clean' the filter
    257261    $filter['date']=$this->getOperator($filter['date'], 'date');
     
    296300        array('id'=>'id', 'direction'=>'A')
    297301      );
     302    // to optimize query, if date is the first field selected for order by,
     303    // all other fields are removed; exception: if IPadress is the second one this
     304    // field is kept
     305    $tmp=$orderBy;
     306    if($tmp[0]['id']=='date')
     307    {
     308      $orderBy=array($tmp[0]);
     309      if($tmp[1]['id']=='IPadress')
     310      {
     311        $orderBy[]=$tmp[1];
     312      }
     313    }
     314
    298315    //build ORDER BY clause
    299316    $orderBy=$this->buildOrderByClause($orderBy);
     
    310327    {
    311328      case ASDF_GET_ROWS:
    312           $sql="SELECT id, date, IPadress, userId, catId, imageId, tagsId, section,
     329          $sql="SELECT id, date, IPadress, country, userId, catId, imageId, tagsId, section,
    313330                       userAgent, uaBrowser, uaBrowserVersion, uaEngine, uaEngineVersion,
    314331                       uaOS, uaOSVersion, uaType, screenSizeW, screenSizeH
    315332                FROM logs $where $orderBy $limit;";
     333
    316334          $sqlStm=$this->dbHandle->prepare($sql);
    317335          foreach($IPList as $num=>$IP)
     
    576594    if(!isset($filter['country'])) $filter['country']=null;
    577595
     596    $filter['IPadress']=$this->checkIPFilter($filter['IPadress']);
    578597    // check filter values - getOperator check and 'clean' the filter
    579598    $filter['IPadress']=$this->getOperator($filter['IPadress'], 'IP');
     
    12481267        DROP TABLE IF EXISTS tmpIp;
    12491268
     1269        -- update the logs table for rows with unset country
     1270        -- use a simple sub select here, assuming that it's quick enough for the update
     1271        UPDATE logs
     1272        SET country=(SELECT sip.country FROM statip sip WHERE logs.IPadress = sip.IPadress)
     1273        WHERE country='';
     1274
    12501275        -- commit changes
    12511276        COMMIT TRANSACTION;
     
    12851310                  'date' INTEGER,
    12861311                  'IPadress' BLOB,
     1312                  'country' TEXT,
    12871313                  'userId' INTEGER,
    12881314                  'catId' INTEGER,
     
    13021328              );"
    13031329            );
    1304           $this->dbHandle->exec("CREATE INDEX iDate ON logs ('date');");
    1305           $this->dbHandle->exec("CREATE INDEX iByIP ON logs ('IPadress');");
     1330          $this->dbHandle->exec("CREATE INDEX iDateIP ON logs ('date', 'IPadress');");
     1331          $this->dbHandle->exec("CREATE INDEX iIPCountry ON logs ('IPadress', 'country');");
     1332          $this->dbHandle->exec("CREATE INDEX iUAB ON logs ('uaType', 'uaBrowser', 'uaEngine');");
     1333          $this->dbHandle->exec("CREATE INDEX iUAO ON logs ('uaOS');");
    13061334        }
    13071335
Note: See TracChangeset for help on using the changeset viewer.