CC-4661: Listener Statistics
- changes for different mount names
This commit is contained in:
parent
8b70136dd6
commit
74fe958cad
|
@ -25,11 +25,8 @@ class ListenerstatController extends Zend_Controller_Action
|
|||
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
//$this->view->headScript()->appendFile($baseUrl.'/js/airtime/playouthistory/historytable.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
|
||||
//$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
|
||||
//$this->view->headLink()->appendStylesheet($baseUrl.'/css/playouthistory.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
||||
//default time is the last 24 hours.
|
||||
$now = time();
|
||||
|
@ -49,6 +46,9 @@ class ListenerstatController extends Zend_Controller_Action
|
|||
'his_time_end' => $end->format("H:i")
|
||||
));
|
||||
|
||||
$allMPs = Application_Model_ListenerStat::getAllMPNames();
|
||||
|
||||
$this->view->mps = $allMPs;
|
||||
$this->view->date_form = $form;
|
||||
}
|
||||
|
||||
|
@ -60,11 +60,12 @@ class ListenerstatController extends Zend_Controller_Action
|
|||
|
||||
$starts_epoch = $request->getParam("startTimestamp", $current_time - (60*60*24));
|
||||
$ends_epoch = $request->getParam("endTimestamp", $current_time);
|
||||
$mountName = $request->getParam("mountName", null);
|
||||
|
||||
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
|
||||
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
|
||||
|
||||
$data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format("Y-m-d H:i:s"), $endsDT->format("Y-m-d H:i:s"));
|
||||
$data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format("Y-m-d H:i:s"), $endsDT->format("Y-m-d H:i:s"), $mountName);
|
||||
die(json_encode($data));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,14 +7,32 @@ class Application_Model_ListenerStat
|
|||
|
||||
public static function getDataPointsWithinRange($p_start, $p_end) {
|
||||
$sql = <<<SQL
|
||||
SELECT cc_listener_count.ID, cc_timestamp.TIMESTAMP, cc_listener_count.LISTENER_COUNT
|
||||
SELECT cc_listener_count.ID, cc_timestamp.TIMESTAMP, cc_listener_count.LISTENER_COUNT, mount_name
|
||||
FROM cc_listener_count
|
||||
INNER JOIN cc_timestamp ON (cc_listener_count.TIMESTAMP_ID=cc_timestamp.ID)
|
||||
WHERE (cc_timestamp.TIMESTAMP>=:p1 AND cc_timestamp.TIMESTAMP<=:p2)
|
||||
ORDER BY cc_timestamp.TIMESTAMP
|
||||
ORDER BY cc_listener_count.mount_name, cc_timestamp.TIMESTAMP
|
||||
SQL;
|
||||
$data = Application_Common_Database::prepareAndExecute($sql, array('p1'=>$p_start, 'p2'=>$p_end));
|
||||
|
||||
return $data;
|
||||
$out = array();
|
||||
foreach ($data as $d) {
|
||||
$out[$d['mount_name']][] = $d;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function getAllMPNames() {
|
||||
$sql = <<<SQL
|
||||
SELECT DISTINCT mount_name
|
||||
FROM cc_listener_count
|
||||
SQL;
|
||||
$mps = Application_Common_Database::prepareAndExecute($sql, array());
|
||||
$out = array();
|
||||
foreach ($mps as $mp) {
|
||||
$out[] = $mp['mount_name'];
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,13 @@
|
|||
<div id="listenerstat_content" class="ui-widget ui-widget-content block-shadow alpha-block padded">
|
||||
Timestamp vs Listener Count
|
||||
Timestamp vs Listener Count<br>
|
||||
<select id='all_mps'>
|
||||
<option value="all">All Mount Potins</option>
|
||||
<?php foreach($this->mps as $mp) {?>
|
||||
<option value="<?php echo $mp?>"><?php echo $mp?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<div id="flot_placeholder" style="width:600px;height:300px;margin:0px 50px 0px 50px"></div>
|
||||
|
||||
<?php echo $this->date_form; ?>
|
||||
|
||||
</div>
|
|
@ -7,24 +7,43 @@ $(document).ready(function() {
|
|||
|
||||
getDataAndPlot();
|
||||
|
||||
listenerstat_content.find("#his_submit").click(function(ev){
|
||||
listenerstat_content.find("#his_submit").click(function(){
|
||||
startTimestamp = AIRTIME.utilities.fnGetTimestamp(dateStartId, timeStartId);
|
||||
endTimestamp = AIRTIME.utilities.fnGetTimestamp(dateEndId, timeEndId);
|
||||
getDataAndPlot(startTimestamp, endTimestamp);
|
||||
});
|
||||
|
||||
listenerstat_content.find("#all_mps").change(function(){
|
||||
var mpName = $(this).val();
|
||||
startTimestamp = AIRTIME.utilities.fnGetTimestamp(dateStartId, timeStartId);
|
||||
endTimestamp = AIRTIME.utilities.fnGetTimestamp(dateEndId, timeEndId);
|
||||
getDataAndPlot(startTimestamp, endTimestamp);
|
||||
getDataAndPlot(startTimestamp, endTimestamp, mpName);
|
||||
})
|
||||
});
|
||||
|
||||
function getDataAndPlot(startTimestamp, endTimestamp){
|
||||
function getDataAndPlot(startTimestamp, endTimestamp, mountName){
|
||||
// get data
|
||||
$.get('/Listenerstat/get-data', {startTimestamp: startTimestamp, endTimestamp: endTimestamp}, function(data){
|
||||
data = JSON.parse(data);
|
||||
out = new Array();
|
||||
$.each(data, function(index, v){
|
||||
temp = new Array();
|
||||
temp[0] = new Date(v.timestamp.replace(/-/g,"/"));
|
||||
temp[1] = v.listener_count;
|
||||
out.push(temp);
|
||||
$.each(data, function(mpName, v){
|
||||
plotData = new Array();
|
||||
if (mountName != null && mpName != mountName){
|
||||
console.log(mountName);
|
||||
return true;
|
||||
}
|
||||
$.each(v, function(i, ele){
|
||||
temp = new Array();
|
||||
temp[0] = new Date(ele.timestamp.replace(/-/g,"/"));
|
||||
temp[1] = ele.listener_count;
|
||||
plotData.push(temp);
|
||||
})
|
||||
out.push(plotData);
|
||||
});
|
||||
if (out.length == 0) {
|
||||
out.push(new Array());
|
||||
}
|
||||
plot(out);
|
||||
})
|
||||
}
|
||||
|
@ -32,7 +51,7 @@ function getDataAndPlot(startTimestamp, endTimestamp){
|
|||
function plot(d){
|
||||
oBaseDatePickerSettings = {
|
||||
dateFormat: 'yy-mm-dd',
|
||||
onSelect: function(sDate, oDatePicker) {
|
||||
onSelect: function(sDate, oDatePicker) {
|
||||
$(this).datepicker( "setDate", sDate );
|
||||
}
|
||||
};
|
||||
|
@ -49,10 +68,6 @@ function plot(d){
|
|||
listenerstat_content.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
||||
listenerstat_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||
|
||||
$.plot($("#flot_placeholder"), [d], { xaxis: { mode: "time", timeformat: "%y/%m/%0d %H:%M:%S" } });
|
||||
|
||||
$("#whole").click(function () {
|
||||
$.plot($("#flot_placeholder"), [d], { xaxis: { mode: "time" } });
|
||||
});
|
||||
$.plot($("#flot_placeholder"), d, { xaxis: { mode: "time", timeformat: "%y/%m/%0d %H:%M:%S" } });
|
||||
|
||||
}
|
Loading…
Reference in New Issue