From 4218a7f30d0eb92a3eff1b42326d57bc947d218a Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 5 Nov 2012 15:48:56 -0500 Subject: [PATCH] CC-4661: Listener Statistics -factor out mountname into it's own table --- airtime_mvc/application/models/ListenerStat.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/models/ListenerStat.php b/airtime_mvc/application/models/ListenerStat.php index 8964bc726..95ea1584d 100644 --- a/airtime_mvc/application/models/ListenerStat.php +++ b/airtime_mvc/application/models/ListenerStat.php @@ -7,13 +7,15 @@ class Application_Model_ListenerStat public static function getDataPointsWithinRange($p_start, $p_end) { $sql = <<=:p1 AND cc_timestamp.TIMESTAMP<=:p2) -ORDER BY cc_listener_count.mount_name, cc_timestamp.TIMESTAMP +SELECT lc.id, ts.timestamp, lc.listener_count, mn.mount_name + FROM cc_listener_count AS lc + INNER JOIN cc_timestamp AS ts ON (lc.timestamp_id = ts.ID) + INNER JOIN cc_mount_name AS mn ON (lc.mount_name_id = mn.ID) +WHERE (ts.timestamp >=:p1 AND ts.timestamp <= :p2) + ORDER BY mount_name, timestamp SQL; - $data = Application_Common_Database::prepareAndExecute($sql, array('p1'=>$p_start, 'p2'=>$p_end)); + $data = Application_Common_Database::prepareAndExecute($sql, + array('p1'=>$p_start, 'p2'=>$p_end)); $out = array(); foreach ($data as $d) { @@ -26,7 +28,7 @@ SQL; public static function getAllMPNames() { $sql = <<