Changeset 14 for stat_functions.php


Ignore:
Timestamp:
Oct 17, 2007, 7:53:48 PM (17 years ago)
Author:
george
Message:

Oprava: Funkce pro přestavbu cache.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stat_functions.php

    r13 r14  
    249249function GetTimeRange($Measure, $Level)
    250250{
    251   global $Debug;
     251  global $Debug, $Database;
    252252 
    253253  // Get first and last time
    254   echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n");
     254  //echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n");
    255255  $Result = $Database->select($Measure['DataTable'], '*', 'measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time LIMIT 1');
    256256  if($Result->num_rows > 0)
     
    395395function RebuildMeasureCache($Measure)
    396396{
    397   global $MaxLevel, $LevelReducing;
    398 
    399   echo('Velicina '.$Measure['Name']."\n");
     397  global $MaxLevel, $LevelReducing, $Database;
     398
     399  echo('Velicina '.$Measure['Name']."<br>\n");
    400400  if($Measure['Continuity'] == 0) $Measure['ContinuityEnabled'] = 0;  // non continuous
    401401    else $Measure['ContinuityEnabled'] = 2;    // continuous graph
    402402
    403403  // Clear previous items
    404   $Result = $Database->select($Measure['DataTable'], 'COUNT(*)', 'level>0 AND measure='.$Measure['Id']);
    405   $Row = $Result->fetch_array();
     404  $DbResult = $Database->select($Measure['DataTable'], 'COUNT(*)', 'level>0 AND measure='.$Measure['Id']);
     405  $Row = $DbResult->fetch_array();
    406406  echo("Mazu starou cache (".$Row[0]." polozek)...");
    407407  $Database->delete($Measure['DataTable'], 'level>0 AND measure='.$Measure['Id']);
    408   echo("\n");
     408  echo("<br>\n");
    409409
    410410  for($Level=1; $Level <= $MaxLevel; $Level++)
    411411  {
    412     echo('Uroven '.$Level."\n");
     412    echo('Uroven '.$Level."<br>\n");
    413413    $TimeRange = GetTimeRange($Measure, $Level-1);
    414414    //echo($Measure['Id'].','.($Level-1)."\n");
     
    418418    $EndTime = AlignTime($TimeRange['right'], $TimeSegment);
    419419    $BurstCount = 500;
    420     echo('For 0 to '.round(($EndTime - $StartTime) / $TimeSegment / $BurstCount)."\n");
     420    echo('For 0 to '.round(($EndTime - $StartTime) / $TimeSegment / $BurstCount)."<br>\n");
    421421    for($I = 0; $I <= round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); $I++)
    422422    {
     
    425425      $EndTime2 = $StartTime + ($I+1) * $BurstCount * $TimeSegment;
    426426      $Values = array();
    427       DB_Select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($StartTime2).'" AND time < "'.
     427      $DbResult = $Database->select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($StartTime2).'" AND time < "'.
    428428        TimeToMysqlDateTime($EndTime2).'" AND measure='.$Measure['Id'].' AND level='.($Level-1).' ORDER BY time');
    429       while($Row = DB_Row())
     429      while($Row = $DbResult->fetch_array())
    430430      {
    431431        $Row['time'] = MysqlDateTimeToTime($Row['time']);
     
    453453            $Point = ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Measure, $Level);
    454454            $Continuity = $SubValues[1]['continuity'];   
    455             DB_Insert($Measure['DataTable'], array('level' => $Level, 'measure' => $Measure['Id'], 'min' => $Point['min'],
     455            $Database->insert($Measure['DataTable'], array('level' => $Level, 'measure' => $Measure['Id'], 'min' => $Point['min'],
    456456              'avg' => $Point['avg'], 'max' => $Point['max'], 'continuity' => $Continuity, 'time' => TimeToMysqlDateTime($StartTime3+($EndTime3-$StartTime3)/2)));
    457457          }       
     
    462462      //array_pop($NextValues);
    463463    } 
    464     echo("Uroven dokoncena\n");         
    465     DB_Select($Measure['DataTable'], 'COUNT(*)', 'level='.$Level.' AND measure='.$Measure['Id']);
    466     $Row = DB_Row();
    467     echo("Vlozeno ".$Row[0]." polozek.\n");
     464    echo("Uroven dokoncena<br>\n");         
     465    $DbResult = $Database->select($Measure['DataTable'], 'COUNT(*)', 'level='.$Level.' AND measure='.$Measure['Id']);
     466    $Row = $DbResult->fetch_array();
     467    echo("Vlozeno ".$Row[0]." polozek.<br>\n");
    468468  }
    469469}   
     
    479479  $Result = $Database->select('measure', '*');
    480480  while($Measures[] = $Result->fetch_array());
    481   array_pop($Measures);
     481    array_pop($Measures);
    482482
    483483  foreach($Measures as $Measure)
Note: See TracChangeset for help on using the changeset viewer.