Changeset 14 for stat_functions.php
- Timestamp:
- Oct 17, 2007, 7:53:48 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
stat_functions.php
r13 r14 249 249 function GetTimeRange($Measure, $Level) 250 250 { 251 global $Debug ;251 global $Debug, $Database; 252 252 253 253 // Get first and last time 254 echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n");254 //echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n"); 255 255 $Result = $Database->select($Measure['DataTable'], '*', 'measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time LIMIT 1'); 256 256 if($Result->num_rows > 0) … … 395 395 function RebuildMeasureCache($Measure) 396 396 { 397 global $MaxLevel, $LevelReducing ;398 399 echo('Velicina '.$Measure['Name']." \n");397 global $MaxLevel, $LevelReducing, $Database; 398 399 echo('Velicina '.$Measure['Name']."<br>\n"); 400 400 if($Measure['Continuity'] == 0) $Measure['ContinuityEnabled'] = 0; // non continuous 401 401 else $Measure['ContinuityEnabled'] = 2; // continuous graph 402 402 403 403 // 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(); 406 406 echo("Mazu starou cache (".$Row[0]." polozek)..."); 407 407 $Database->delete($Measure['DataTable'], 'level>0 AND measure='.$Measure['Id']); 408 echo(" \n");408 echo("<br>\n"); 409 409 410 410 for($Level=1; $Level <= $MaxLevel; $Level++) 411 411 { 412 echo('Uroven '.$Level." \n");412 echo('Uroven '.$Level."<br>\n"); 413 413 $TimeRange = GetTimeRange($Measure, $Level-1); 414 414 //echo($Measure['Id'].','.($Level-1)."\n"); … … 418 418 $EndTime = AlignTime($TimeRange['right'], $TimeSegment); 419 419 $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"); 421 421 for($I = 0; $I <= round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); $I++) 422 422 { … … 425 425 $EndTime2 = $StartTime + ($I+1) * $BurstCount * $TimeSegment; 426 426 $Values = array(); 427 DB_Select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($StartTime2).'" AND time < "'.427 $DbResult = $Database->select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($StartTime2).'" AND time < "'. 428 428 TimeToMysqlDateTime($EndTime2).'" AND measure='.$Measure['Id'].' AND level='.($Level-1).' ORDER BY time'); 429 while($Row = DB_Row())429 while($Row = $DbResult->fetch_array()) 430 430 { 431 431 $Row['time'] = MysqlDateTimeToTime($Row['time']); … … 453 453 $Point = ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Measure, $Level); 454 454 $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'], 456 456 'avg' => $Point['avg'], 'max' => $Point['max'], 'continuity' => $Continuity, 'time' => TimeToMysqlDateTime($StartTime3+($EndTime3-$StartTime3)/2))); 457 457 } … … 462 462 //array_pop($NextValues); 463 463 } 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"); 468 468 } 469 469 } … … 479 479 $Result = $Database->select('measure', '*'); 480 480 while($Measures[] = $Result->fetch_array()); 481 array_pop($Measures);481 array_pop($Measures); 482 482 483 483 foreach($Measures as $Measure)
Note:
See TracChangeset
for help on using the changeset viewer.