Skip to content

Commit fa13bd1

Browse files
committed
fix 1 day offset for top list range
Top lists are either generated for "today" or for the whole display range. The underlying query however returns one day more than expected, if storage range is greater display range.
1 parent eab1d2e commit fa13bd1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. This projec
44
## unreleased
55
* Prevent JavaScript tracking from raising 400 for logged-in users, if tracking is disabled (#159)
66
* Use `wp_die()` instead of header and exit for AJAX requests (#160)
7+
* Fix 1 day offset between display range and number of days evaluated in top lists (#161)
78

89
## 1.7.1
910
* Fix refresh of the dashboard widget when settings have been changed through the settings page (#147)

inc/class-statify-dashboard.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ private static function _select_data() {
346346
} else {
347347
$data['target'] = $wpdb->get_results(
348348
$wpdb->prepare(
349-
"SELECT COUNT(`target`) as `count`, `target` as `url` FROM `$wpdb->statify` WHERE created >= DATE_SUB(%s, INTERVAL %d DAY) GROUP BY `target` ORDER BY `count` DESC LIMIT %d",
349+
"SELECT COUNT(`target`) as `count`, `target` as `url` FROM `$wpdb->statify` WHERE created > DATE_SUB(%s, INTERVAL %d DAY) GROUP BY `target` ORDER BY `count` DESC LIMIT %d",
350350
$current_date,
351351
$days_show,
352352
$limit
@@ -355,7 +355,7 @@ private static function _select_data() {
355355
);
356356
$data['referrer'] = $wpdb->get_results(
357357
$wpdb->prepare(
358-
"SELECT COUNT(`referrer`) as `count`, `referrer` as `url`, SUBSTRING_INDEX(SUBSTRING_INDEX(TRIM(LEADING 'www.' FROM(TRIM(LEADING 'https://' FROM TRIM(LEADING 'http://' FROM TRIM(`referrer`))))), '/', 1), ':', 1) as `host` FROM `$wpdb->statify` WHERE `referrer` != '' AND created >= DATE_SUB(%s, INTERVAL %d DAY) GROUP BY `host` ORDER BY `count` DESC LIMIT %d",
358+
"SELECT COUNT(`referrer`) as `count`, `referrer` as `url`, SUBSTRING_INDEX(SUBSTRING_INDEX(TRIM(LEADING 'www.' FROM(TRIM(LEADING 'https://' FROM TRIM(LEADING 'http://' FROM TRIM(`referrer`))))), '/', 1), ':', 1) as `host` FROM `$wpdb->statify` WHERE `referrer` != '' AND created > DATE_SUB(%s, INTERVAL %d DAY) GROUP BY `host` ORDER BY `count` DESC LIMIT %d",
359359
$current_date,
360360
$days_show,
361361
$limit

0 commit comments

Comments
 (0)