s ) * 100 ) : 0; $date_completed = ( new \DateTime( 'now', wp_timezone() ) )->setTimestamp( $state->get( 'complete_timestamp' ) ); $estimated_time_in_seconds = $state->get( 'migration', 'estimated_time_in_seconds' ) + ( 60 * 5 ); $data = [ 'estimated_time_in_seconds' => $estimated_time_in_seconds, 'estimated_time_in_minutes' => round( $estimated_time_in_seconds / 60, 0 ), 'date_completed' => $date_completed->format( 'F j, Y, g:i a' ), 'completed_timestamp' => $date_completed->getTimestamp(), 'total_events_in_progress' => $total_events_in_progress, 'total_events_migrated' => $total_events_migrated, 'total_events' => $total_events, 'total_events_remaining' => $total_events_remaining, 'total_events_failed' => $total_events_with_failure, 'has_changes' => $total_events_migrated > 0, 'migration_phase' => $state->get_phase(), 'is_completed' => $state->is_completed(), 'is_running' => $state->is_running(), 'progress_percent' => $progress_percent, 'has_errors' => $total_events_with_failure > 0 ]; return new Site_Report( $data ); } /** * Retrieves a sorted list of Event_Report objects. * * @since 6.0.0 * * @param int $page The page to retrieve in a pagination request. If -1, it will retrieve all * reports in the database. * @param int $count The number of event reports to retrieve. If $page is -1 this will be * ignored. * @param array $filter An option set of filters to apply to the search. * * @return array A sorted list of Event_Report objects. */ public function get_event_reports( $page = - 1, $count = 20, $filter = [] ) { $event_repo = tribe( Events::class ); // Get all the events that have been touched by migration $post_ids = $event_repo->get_events_migrated( $page, $count, $filter ); $event_reports = []; foreach ( $post_ids as $post_id ) { $event_reports[] = new Event_Report( get_post( $post_id ) ); } return $event_reports; } /** * Get all of the site report data. * * @since 6.0.0 * * @return array */ public function get_data() { return $this->data; } /** * Getter for site report data. * * @since 6.0.0 * * @param string $prop The key of the data. * * @return mixed|null */ public function __get( $prop ) { return isset( $this->data[ $prop ] ) ? $this->data[ $prop ] : null; } /** * The JSON serializer. * * @since 6.0.0 */ #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->data; } }