From 0c40cacc83864f879f64f1deb0aae3ccd70962e2 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 28 Dec 2016 13:48:28 +0000 Subject: [PATCH 1/3] Provide a minimal valid array if there have are no blocked queries at all. Otherwise the output of the API is inconsistent. --- data.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/data.php b/data.php index aeba20f4..2451619a 100644 --- a/data.php +++ b/data.php @@ -68,6 +68,16 @@ $domains_over_time = overTime10mins($dns_queries); $ads_over_time = overTime10mins($ads_blocked); + + // Provide a minimal valid array if there have are no blocked + // queries at all. Otherwise the output of the API is inconsistent. + if(count($ads_blocked) == 0) + { + $ads_over_time = [1 => 0]; + } + + print_r($domains_over_time); + alignTimeArrays($ads_over_time, $domains_over_time); return Array( 'domains_over_time' => $domains_over_time, From f0b4d0f27da9779e5d6c138408c00b3a602a4933 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 28 Dec 2016 13:52:24 +0000 Subject: [PATCH 2/3] Apply the same fix for function getOverTimeData() --- data.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/data.php b/data.php index 2451619a..374a67d4 100644 --- a/data.php +++ b/data.php @@ -54,6 +54,14 @@ $domains_over_time = overTime($dns_queries); $ads_over_time = overTime($ads_blocked); + + // Provide a minimal valid array if there have are no blocked + // queries at all. Otherwise the output of the API is inconsistent. + if(count($ads_blocked) == 0) + { + $ads_over_time = [1 => 0]; + } + alignTimeArrays($ads_over_time, $domains_over_time); return Array( 'domains_over_time' => $domains_over_time, From bc5779376180ae72e35c00a75a1787817f4656e9 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 28 Dec 2016 16:55:59 +0100 Subject: [PATCH 3/3] Remove debug statement --- data.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/data.php b/data.php index 374a67d4..ad24e57e 100644 --- a/data.php +++ b/data.php @@ -84,8 +84,6 @@ $ads_over_time = [1 => 0]; } - print_r($domains_over_time); - alignTimeArrays($ads_over_time, $domains_over_time); return Array( 'domains_over_time' => $domains_over_time,