Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add created_at timestamp to the Events #115

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions includes/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class Event {
public $user;

/**
* Timestamp when the event occurred
* DateTime when the event occurred
*
* @var integer
* @var string
*/
public $time;
public $created_at;

/**
* Construct
Expand All @@ -60,7 +60,7 @@ public function __construct( $category = 'Admin', $key = '', $data = array() ) {
global $title;

// Event details
$this->time = time();
$this->created_at = date( 'Y-m-d H:i:s.u' );
$this->category = strtolower( $category );
$this->key = $key;
$this->data = $data;
Expand Down
6 changes: 5 additions & 1 deletion includes/EventQueue/Queues/BatchQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ public function pull( int $count ) {

foreach ( $rawEvents as $rawEvent ) {
if ( property_exists( $rawEvent, 'id' ) && property_exists( $rawEvent, 'event' ) ) {
$events[ $rawEvent->id ] = maybe_unserialize( $rawEvent->event );
$eventData = maybe_unserialize( $rawEvent->event );
if ( is_array( $eventData ) && property_exists( $rawEvent, 'created_at' ) ) {
$eventData['created_at'] = $rawEvent->created_at;
}
$events[ $rawEvent->id ] = $eventData;
}
}

Expand Down
Loading