Changeset 1058 for trunk


Ignore:
Timestamp:
2012-07-27T10:10:24+02:00 (2 years ago)
Author:
moo
Message:

cacher/htdocs: same scale in same cache type for hits graph

Location:
trunk/htdocs/cacher
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/cacher/cacher.php

    r1053 r1058  
    9292} 
    9393 
    94 function hits_to_graph($hits) 
    95 { 
    96     $max = 0; 
    97     foreach ($hits as $v) { 
    98         if ($max < $v) { 
    99             $max = $v; 
    100         } 
     94function get_cache_hits_graph($ci, $key) 
     95{ 
     96    if ($ci['cacheid'] == -1) { 
     97        $max = max($ci[$key]); 
     98    } 
     99    else { 
     100        $max = $GLOBALS['maxhits_by_hour'][$ci['type']]; 
    101101    } 
    102102    if (!$max) { 
    103         return ''; 
     103        $max = 1; 
    104104    } 
    105105    $t = (time() / (60 * 60)) % 24; 
    106106    $html = array(); 
    107     foreach ($hits as $i => $v) { 
     107    foreach ($ci[$key] as $i => $v) { 
    108108        $html[] = bar_hits_percent($v, $v / $max, $i == $t); 
    109109    } 
     
    185185$cacheinfos = array(); 
    186186$total = array(); 
     187$maxhits_by_hour = array(0, 0); 
    187188for ($i = 0; $i < $pcnt; $i ++) { 
    188189    $data = xcache_info(XC_TYPE_PHP, $i); 
     
    194195    $data['cacheid'] = $i; 
    195196    $cacheinfos[] = $data; 
     197    $maxhits_by_hour[XC_TYPE_PHP] = max($maxhits_by_hour[XC_TYPE_PHP], max($data['hits_by_hour'])); 
    196198    if ($pcnt >= 2) { 
    197199        calc_total($total, $data); 
     
    218220    $data['cacheid'] = $i; 
    219221    $cacheinfos[] = $data; 
     222    $maxhits_by_hour[XC_TYPE_VAR] = max($maxhits_by_hour[XC_TYPE_VAR], max($data['hits_by_hour'])); 
    220223    if ($vcnt >= 2) { 
    221224        calc_total($total, $data); 
  • trunk/htdocs/cacher/cacher.tpl.php

    r1053 r1058  
    8484        $hits_avg_h     = number_format(array_avg($ci['hits_by_hour']), 2); 
    8585        $hits_avg_s     = number_format(array_avg($ci['hits_by_second']), 2); 
    86         $hits_graph_h   = hits_to_graph($ci['hits_by_hour']); 
     86        $hits_graph_h   = get_cache_hits_graph($ci, 'hits_by_hour'); 
    8787        $hits_graph_h_w = count($ci['hits_by_hour']) * 2; 
    8888 
Note: See TracChangeset for help on using the changeset viewer.