| @@ -21,9 +21,9 @@ | ||
| 21 | 21 | * Return the report title |
| 22 | 22 | * |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | - public function get_title() : string { | |
| 25 | + public function get_title(): string { | |
| 26 | 26 | return __( 'Last Sync', 'elasticpress' ); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
| @@ -30,26 +30,15 @@ | ||
| 30 | 30 | * Return the report fields |
| 31 | 31 | * |
| 32 | 32 | * @return array |
| 33 | 33 | */ |
| 34 | - public function get_groups() : array { | |
| 35 | - $title = __( 'Last Sync', 'elasticpress' ); | |
| 34 | + public function get_groups(): array { | |
| 36 | 35 | $fields = []; |
| 37 | 36 | |
| 38 | - $sync_info = \ElasticPress\IndexHelper::factory()->get_last_index(); | |
| 37 | + $sync_info = \ElasticPress\IndexHelper::factory()->get_last_sync(); | |
| 39 | 38 | |
| 40 | 39 | if ( empty( $sync_info ) ) { |
| 41 | - $fields['not_available'] = [ | |
| 42 | - 'label' => esc_html__( 'Last Sync', 'elasticpress' ), | |
| 43 | - 'value' => esc_html__( 'Last sync info not available.', 'elasticpress' ), | |
| 44 | - ]; | |
| 45 | - | |
| 46 | - return [ | |
| 47 | - [ | |
| 48 | - 'title' => $title, | |
| 49 | - 'fields' => $fields, | |
| 50 | - ], | |
| 51 | - ]; | |
| 40 | + return []; | |
| 52 | 41 | } |
| 53 | 42 | |
| 54 | 43 | if ( ! empty( $sync_info['end_time_gmt'] ) ) { |
| 55 | 44 | unset( $sync_info['end_time_gmt'] ); |
| @@ -81,8 +70,12 @@ | ||
| 81 | 70 | |
| 82 | 71 | $sync_info['method'] = $methods[ $sync_info['method'] ] ?? $sync_info['method']; |
| 83 | 72 | } |
| 84 | 73 | |
| 74 | + if ( isset( $sync_info['is_full_sync'] ) ) { | |
| 75 | + $sync_info['is_full_sync'] = $sync_info['is_full_sync'] ? esc_html__( 'Yes', 'elasticpress' ) : esc_html__( 'No', 'elasticpress' ); | |
| 76 | + } | |
| 77 | + | |
| 85 | 78 | $labels = [ |
| 86 | 79 | 'total' => esc_html__( 'Total', 'elasticpress' ), |
| 87 | 80 | 'synced' => esc_html__( 'Synced', 'elasticpress' ), |
| 88 | 81 | 'skipped' => esc_html__( 'Skipped', 'elasticpress' ), |
| @@ -88,8 +81,9 @@ | ||
| 88 | 81 | 'skipped' => esc_html__( 'Skipped', 'elasticpress' ), |
| 89 | 82 | 'failed' => esc_html__( 'Failed', 'elasticpress' ), |
| 90 | 83 | 'errors' => esc_html__( 'Errors', 'elasticpress' ), |
| 91 | 84 | 'method' => esc_html__( 'Method', 'elasticpress' ), |
| 85 | + 'is_full_sync' => esc_html__( 'Full Sync', 'elasticpress' ), | |
| 92 | 86 | 'end_date_time' => esc_html__( 'End Date Time', 'elasticpress' ), |
| 93 | 87 | 'start_date_time' => esc_html__( 'Start Date Time', 'elasticpress' ), |
| 94 | 88 | 'total_time' => esc_html__( 'Total Time', 'elasticpress' ), |
| 95 | 89 | ]; |
| @@ -100,9 +94,9 @@ | ||
| 100 | 94 | * As some rows could be unavailable (if the last sync was done using an older version of the plugin, for example), |
| 101 | 95 | * the usual `array_replace(array_flip())` strategy to reorder an array adds a wrong numeric value to the |
| 102 | 96 | * non-existent row. |
| 103 | 97 | */ |
| 104 | - $preferred_order = [ 'method', 'start_date_time', 'end_date_time', 'total_time', 'total', 'synced', 'skipped', 'failed', 'errors' ]; | |
| 98 | + $preferred_order = [ 'method', 'is_full_sync', 'start_date_time', 'end_date_time', 'total_time', 'total', 'synced', 'skipped', 'failed', 'errors' ]; | |
| 105 | 99 | $ordered_sync_info = []; |
| 106 | 100 | foreach ( $preferred_order as $field ) { |
| 107 | 101 | if ( array_key_exists( $field, $sync_info ) ) { |
| 108 | 102 | $ordered_sync_info[ $field ] = $sync_info[ $field ] ?? esc_html_x( 'N/A', 'Sync info not available', 'elasticpress' ); |
| @@ -115,8 +109,16 @@ | ||
| 115 | 109 | $fields[ sanitize_title( $label ) ] = [ |
| 116 | 110 | 'label' => $labels[ $label ] ?? $label, |
| 117 | 111 | 'value' => $value, |
| 118 | 112 | ]; |
| 113 | + } | |
| 114 | + $title = $sync_info['start_date_time'] ?? ''; | |
| 115 | + if ( false !== \ElasticPress\Utils\get_indexing_status() ) { | |
| 116 | + /* translators: last sync title */ | |
| 117 | + $title = sprintf( __( '%s (In Progress)', 'elasticpress' ), $title ); | |
| 118 | + } | |
| 119 | + if ( 'status-report' === \ElasticPress\Screen::factory()->get_current_screen() ) { | |
| 120 | + unset( $fields['start_date_time'] ); | |
| 119 | 121 | } |
| 120 | 122 | |
| 121 | 123 | return [ |
| 122 | 124 | [ |