CC-3993: Validate that reporting stats are correct on Airtime PRO instances

-done
-if no log data for the past 24 hours, update current record with current date, and delete old records
This commit is contained in:
denise 2012-06-19 16:59:59 -04:00
parent 27a6326c58
commit 9ac024fa72
1 changed files with 175 additions and 136 deletions

View File

@ -20,12 +20,30 @@ class Application_Model_LiveLog
if ($rows != null) {
$last_row = self::UpdateLastLogEndTime(array_pop($rows));
array_push($rows, $last_row);
$skip = false;
} else {
$sql = "SELECT * FROM CC_LIVE_LOG"
." WHERE state = 'L'"
." ORDER BY id";
$rows = $con->query($sql)->fetchAll();
if ($rows != null) {
$last_row = self::UpdateLastLogEndTime(array_pop($rows));
array_push($rows, $last_row);
foreach ($rows as $row) {
$sql_delete = "DELETE FROM CC_LIVE_LOG"
." WHERE id = '{$row['id']}'";
$con->exec($sql_delete);
}
}
$skip = true;
}
$hours = 0;
$minutes = 0;
$seconds = 0;
if (!$skip) {
foreach ($rows as $row) {
$end = new DateTime($row['end_time']);
$start = new DateTime($row['start_time']);
@ -73,6 +91,7 @@ class Application_Model_LiveLog
else {
$minutes = (double)(($hours*60)+$minutes);
}
}
return $minutes;
} catch (Exception $e) {
header('HTTP/1.0 503 Service Unavailable');
@ -99,12 +118,31 @@ class Application_Model_LiveLog
if ($rows != null) {
$last_row = self::UpdateLastLogEndTime(array_pop($rows));
array_push($rows, $last_row);
$skip = false;
}
else {
$sql = "SELECT * FROM CC_LIVE_LOG"
." WHERE state = 'S'"
." ORDER BY id";
$rows = $con->query($sql)->fetchAll();
if ($rows != null) {
$last_row = self::UpdateLastLogEndTime(array_pop($rows));
array_push($rows, $last_row);
foreach ($rows as $row) {
$sql_delete = "DELETE FROM CC_LIVE_LOG"
." WHERE id = '{$row['id']}'";
$con->exec($sql_delete);
}
}
$skip = true;
}
$hours = 0;
$minutes = 0;
$seconds = 0;
if (!$skip) {
/* Get all shows and tracks from cc_schedule that played
* during a scheduled state
*/
@ -215,6 +253,7 @@ class Application_Model_LiveLog
else {
$minutes = (double)(($hours*60)+$minutes);
}
}
return $minutes;
} catch (Exception $e) {
header('HTTP/1.0 503 Service Unavailable');