Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Auto-switch graph frequency to avoid super-heavy graphs.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Oct 6, 2015
1 parent 1709785 commit f537d48
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/plugins/log.sql/class.sqlLogDriver.php
Expand Up @@ -85,7 +85,7 @@ private function getQuery($queryName){
return false;
}

protected function processOneQuery($queryName, $start, $count, $frequency="day", $additionalFilters=array()){
protected function processOneQuery($queryName, $start, $count, $frequency="auto", $additionalFilters=array()){

$query = $this->getQuery($queryName);
if($query === false){
Expand Down Expand Up @@ -119,6 +119,10 @@ protected function processOneQuery($queryName, $start, $count, $frequency="day",
$allDates = array();

if(isSet($query["AXIS"]) && $query["AXIS"]["x"] == "Date"){
if($frequency == "auto"){
if($count > 70) $frequency = "month";
else if($count > 21) $frequency = "week";
}
$groupedSums = array();
if($frequency == "week"){
$groupByFormat = "W";
Expand Down Expand Up @@ -197,7 +201,7 @@ public function processQuery($actionName, &$httpVars, &$fileVars){
$query_name = $httpVars["query_name"];
$start = 0;
$count = 30;
$frequency = (isSet($httpVars["frequency"])?AJXP_Utils::sanitize($httpVars["frequency"], AJXP_SANITIZE_ALPHANUM):"day");
$frequency = (isSet($httpVars["frequency"])?AJXP_Utils::sanitize($httpVars["frequency"], AJXP_SANITIZE_ALPHANUM):"auto");
if(isSet($httpVars["start"])) $start = intval($httpVars["start"]);
if(isSet($httpVars["count"])) $count = intval($httpVars["count"]);
$additionalFilters = array();
Expand Down

0 comments on commit f537d48

Please sign in to comment.