Skip to content

Commit

Permalink
Add in per month sparkbars and fix an issue where some months have le…
Browse files Browse the repository at this point in the history
…ss then 31 days. This will "cluster" end of month jobs around the 28-31 range rather then a single date, but will actually calculate the per day stats better.
  • Loading branch information
kormoc committed May 9, 2012
1 parent 4a5fbb5 commit ff2fdaf
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions review.php
Expand Up @@ -62,8 +62,11 @@ function timeStats($row) {
}

// Day of month
// This won't work beyond a single month stretch, but that seems unlikely right now
// Also known as bug #123 that will bite me in the butt for saying it's unlikely
$ts_min = date('j', strtotime($row['ts_min']));
$ts_max = date('j', strtotime($row['ts_max']));
$max = date('t', strtotime($row['ts_min']));

if ($ts_min == $ts_max) {
@$historyDataTime['monthday'][$ts_max] += $row['ts_cnt'];
Expand All @@ -74,8 +77,8 @@ function timeStats($row) {
while ($i != $ts_max) {
$cnt++;
$i++;
if ($i >= 31)
$i -= 31;
if ($i >= $max)
$i -= $max;
}

$per = $row['ts_cnt'] / $cnt;
Expand All @@ -84,10 +87,37 @@ function timeStats($row) {
while ($i != $ts_max) {
@$historyDataTime['monthday'][$i] += $per;
$i++;
if ($i >= 31)
$i -= 31;
if ($i >= $max)
$i -= $max;
}
}
// Month
$ts_min = date('n', strtotime($row['ts_min']));
$ts_max = date('n', strtotime($row['ts_max']));

if ($ts_min == $ts_max) {
@$historyDataTime['month'][$ts_min] += $row['ts_cnt'];
}
else {
$cnt = 1;
$i = $ts_min;
while ($i != $ts_max) {
$cnt++;
$i++;
if ($i >= 12)
$i -= 12;
}

$per = $row['ts_cnt'] / $cnt;

$i = $ts_min;
while ($i != $ts_max) {
@$historyDataTime['month'][$i] += $per;
$i++;
if ($i >= 12)
$i -= 12;
}
}
}

// Scan for valid databases to explain against
Expand Down Expand Up @@ -141,6 +171,7 @@ function timeStats($row) {
'hours' => array(),
'weekday' => array(),
'monthday' => array(),
'month' => array(),
);

if (strlen($reviewhost['history_table'])) {
Expand Down Expand Up @@ -366,6 +397,16 @@ function timeStats($row) {
}
?>
</span><br>
Months <span class="inlinesparkbar" style="float: right;">
<?php
for ($i = 0; $i < 12; $i++) {
if (!isset($historyDataTime['month'][$i]))
echo "0,";
else
echo round($historyDataTime['month'][$i], 0).",";
}
?>
</span><br>
</div>

Seen between <?php echo $reviewData['first_seen']; ?> and <?php echo $reviewData['last_seen']; ?>.
Expand Down

0 comments on commit ff2fdaf

Please sign in to comment.