From 14fe50136b542daf12963510241aeb28c25aa3a7 Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Tue, 12 May 2020 20:58:58 +0200 Subject: [PATCH] fix inconsistency between number of total visits and first date Date has been taken from the first data point of the output range while the total number of hits is directly requested from the database. Now the first date is also qeueried along with the taotal count. --- CHANGELOG.md | 3 +++ inc/class-statify-dashboard.php | 5 +++-- views/widget-front.php | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3ffc79..38b676c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## unreleased +* Fix date inconsistency for number of total visits (#150) + ## 1.7.0 * Fix JavaScript embedding when bots visit before caching (#84) (#86) * Fix offset in visitor reporting due to different timezones between PHP and database (#117, props @sophiehuiberts) diff --git a/inc/class-statify-dashboard.php b/inc/class-statify-dashboard.php index df7cee6..43c292c 100644 --- a/inc/class-statify-dashboard.php +++ b/inc/class-statify-dashboard.php @@ -380,8 +380,9 @@ private static function _select_data() { $current_date ) ), - 'since_beginning' => $wpdb->get_var( - "SELECT COUNT(`created`) FROM `$wpdb->statify`" + 'since_beginning' => $wpdb->get_row( + "SELECT COUNT(`created`) AS `count`, MIN(`created`) AS `date` FROM `$wpdb->statify`", + ARRAY_A ), ); } diff --git a/views/widget-front.php b/views/widget-front.php index 6c47761..5c47377 100644 --- a/views/widget-front.php +++ b/views/widget-front.php @@ -101,11 +101,11 @@ class_exists( 'Statify' ) || exit; - + - +