From: Maxious Date: Sat, 20 Oct 2012 06:30:02 +0000 Subject: fix viewcalls X-Git-Url: https://maxious.lambdacomplex.org/git/?p=scannr.git&a=commitdiff&h=6ea412b2ab82d10acedb8c5641e224fa00dfb068 --- fix viewcalls --- --- /dev/null +++ b/.idea/dictionaries/Madoka.xml @@ -1,1 +1,10 @@ - + + + + tgid + timefrom + timeto + tzoffset + + + --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,10 +2,11 @@ + - + @@ -29,11 +30,8 @@ - - - - - + + @@ -41,7 +39,7 @@ - + @@ -50,7 +48,7 @@ - + @@ -70,8 +68,8 @@ @@ -109,7 +107,6 @@ - @@ -130,6 +127,7 @@ + @@ -137,8 +135,8 @@ + - @@ -150,7 +148,7 @@ - @@ -178,6 +176,7 @@ + 1350026709905 1350026709905 @@ -187,23 +186,23 @@ - + - + - + - - + + - + + - + - @@ -259,75 +258,79 @@ + + + + + + + + + + + + + + + + + + + + + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - - - + + - + - + --- a/calls.json.php +++ b/calls.json.php @@ -1,66 +1,70 @@ prepare( 'select min(call_timestamp) as time, count(*), min(length), max(length), avg(length), stddev(length) from recordings group by tgid, date_trunc(\'hour\', call_timestamp) order by time'); - $sth->execute( Array($sensorID, $timeFrom, $timeTo)); - return $sth->fetchAll(); + $sth->execute( ); + //Array($TGID, $timeFrom, $timeTo) + return $sth->fetchAll(); + + } -function getSensorValuesByDay($sensorID, $dayFrom, $dayTo) { +function getTGIDValuesByDay($TGID, $dayFrom, $dayTo) { global $conn; $sth = $conn->prepare('select min(time) as time, min(value), max(value), avg(value), stddev(value) from sensor_values where sensor_id = ? group by sensor_id, date_trunc(\'day\', time) order by time'); - $sth->execute( Array($sensorID)); + $sth->execute( Array($TGID)); return $sth->fetchAll(); } -function getSensorDataYears($sensorID, $timeFrom, $timeTo) { +function getTGIDDataYears($TGID, $timeFrom, $timeTo) { global $conn; $sth = $conn->prepare("select distinct extract('year' from call_timestamp) as year from recordings where tgid = ? order by year"); - $sth->execute(Array($sensorID)); + $sth->execute(Array($TGID)); return $sth->fetchAll(); } -function getSensorDataMonths($sensorID, $timeFrom, $timeTo) { +function getTGIDDataMonths($TGID, $timeFrom, $timeTo) { global $conn; $sth = $conn->prepare("select distinct extract('month' from call_timestamp) as month, extract('year' from call_timestamp) as year from recordings where tgid = ? order by year, month"); - $sth->execute(Array($sensorID)); + $sth->execute(Array($TGID)); return $sth->fetchAll(); } -function getSensorDataDays($sensorID, $timeFrom, $timeTo) { +function getTGIDDataDays($TGID, $timeFrom, $timeTo) { global $conn; $sth = $conn->prepare("select distinct extract('day' from call_timestamp) as day, extract('month' from call_timestamp) as month, extract('year' from call_timestamp) as year from recordings where tgid = ? order by year,month,day"); - $sth->execute(Array($sensorID)); + $sth->execute(Array($TGID)); return $sth->fetchAll(); } -$action = $_REQUEST['action']; - $sensorID = $_REQUEST['tgid']; -$timefrom = $_REQUEST['from']; -$timeto = $_REQUEST['to']; -if ($action = "data_description") { +$action = (isset($_REQUEST['action']) ? $_REQUEST['action'] : ''); +$TGID = (isset($_REQUEST['tgid']) ? $_REQUEST['tgid'] : ''); +$timefrom = (isset($_REQUEST['from']) ? $_REQUEST['from'] : ''); +$timeto = (isset($_REQUEST['to']) ? $_REQUEST['to'] : ''); + +if ($action == "data_description") { $timefrom = strtotime($timefrom); $timeto = strtotime($timeto); - $years = getSensorDataYears($sensorID, $timefrom, $timeto); + $years = getTGIDDataYears($TGID, $timefrom, $timeto); - $months = getSensorDataMonths($sensorID, $timefrom, $timeto); - $days = getSensorDataDays($sensorID, $timefrom, $timeto); + $months = getTGIDDataMonths($TGID, $timefrom, $timeto); + $days = getTGIDDataDays($TGID, $timefrom, $timeto); echo json_encode(Array("years" => $years, "months" => $months, "days" => $days )); } -if ($action = "graph") { - $values = getSensorValuesByHour($sensorID, $timefrom, $timeto); - $label = $sensorID; +if ($action == "graph") { + $values = getTGIDValuesByHour($TGID, $timefrom, $timeto); + $label = $TGID; $data = Array(); $tzoffset = get_timezone_offset("UTC"); foreach ($values as $value) { --- a/common.inc.php +++ b/common.inc.php @@ -10,6 +10,7 @@ catch(Exception $e) { die('Unknown error in ' . __FILE__ . '.'); } +$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $basePath = ""; $DATA_DIR = "./data"; @@ -57,7 +58,7 @@ - + --- a/viewcalls.php +++ b/viewcalls.php @@ -53,7 +53,7 @@ }); - getData('','',''); + getData('','',''); }); @@ -61,7 +61,7 @@ data =[] data[data.length] = series; - plot = $.plot($("#placeholder"), data, options); + plot =Flotr.draw(placeholder, data, options); } function getData(sensorID,from,to) { $.ajax({