Skip to content

Commit

Permalink
fix: take timestamp difference into account
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek committed Feb 27, 2024
1 parent 62fdf8d commit ca136ae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion includes/hub/stores/class-event-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ function( $v ) {
}

if ( ! empty( $args['timestamp'] ) ) {
$where .= $wpdb->prepare( ' AND timestamp = %s', $args['timestamp'] );
// The logged event timestamp and the actual timestamp of the event can differ by a few seconds,
// so we need to search for a range of timestamps.
$timestamp = $args['timestamp'];
$range = 3; // seconds.
$where .= $wpdb->prepare( ' AND timestamp >= %s AND timestamp <= %s', $timestamp - $range, $timestamp + $range );
}

if ( ! empty( $args['data'] ) ) {
Expand Down

0 comments on commit ca136ae

Please sign in to comment.