Skip to content

Commit

Permalink
fix inconsistency between number of total visits and first date
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stklcode committed May 12, 2020
1 parent 6d3910c commit e402be2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 3 additions & 2 deletions inc/class-statify-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
);
}
Expand Down
4 changes: 2 additions & 2 deletions views/widget-front.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ class_exists( 'Statify' ) || exit;
</tr>
<tr>
<td class="b">
<?php echo (int) $stats['visit_totals']['since_beginning']; ?>
<?php echo (int) $stats['visit_totals']['since_beginning']['count']; ?>
</td>
<td class="t">
<?php esc_html_e( 'since', 'statify' ); ?>
<?php echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $stats['visits'][0]['date'] ) ) ); ?>
<?php echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $stats['visit_totals']['since_beginning']['date'] ) ) ); ?>
</td>
</tr>
</table>
Expand Down

0 comments on commit e402be2

Please sign in to comment.