Skip to content

Commit

Permalink
Add created_at to the Events
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-vara committed Dec 4, 2024
1 parent 7c1abaa commit 8b1883a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion includes/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ class Event {
*/
public $time;

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

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

// Event details
$this->time = time();
$this->time = time(); // TODO: Remove this if not used anywhere
$this->created_at = current_time( 'mysql' );
$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

0 comments on commit 8b1883a

Please sign in to comment.