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

Status Report: Add if full sync or not to Last Sync #3304

Merged
merged 1 commit into from
Feb 8, 2023
Merged
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: 5 additions & 3 deletions includes/classes/IndexHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,10 @@ protected function index_cleanup() {
* @since 4.2.0
*/
protected function update_last_index() {
$start_time = $this->index_meta['start_time'];
$totals = $this->index_meta['totals'];
$method = $this->index_meta['method'];
$start_time = $this->index_meta['start_time'];
$totals = $this->index_meta['totals'];
$method = $this->index_meta['method'];
$is_full_sync = $this->index_meta['put_mapping'];

$this->index_meta = null;

Expand All @@ -820,6 +821,7 @@ protected function update_last_index() {
$totals['end_time_gmt'] = time();
$totals['total_time'] = microtime( true ) - $start_time;
$totals['method'] = $method;
$totals['is_full_sync'] = $is_full_sync;
Utils\update_option( 'ep_last_cli_index', $totals, false );
Utils\update_option( 'ep_last_index', $totals, false );
}
Expand Down
7 changes: 6 additions & 1 deletion includes/classes/StatusReport/LastSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,18 @@ public function get_groups() : array {
$sync_info['method'] = $methods[ $sync_info['method'] ] ?? $sync_info['method'];
}

if ( isset( $sync_info['is_full_sync'] ) ) {
$sync_info['is_full_sync'] = $sync_info['is_full_sync'] ? esc_html__( 'Yes', 'elasticpress' ) : esc_html__( 'No', 'elasticpress' );
}

$labels = [
'total' => esc_html__( 'Total', 'elasticpress' ),
'synced' => esc_html__( 'Synced', 'elasticpress' ),
'skipped' => esc_html__( 'Skipped', 'elasticpress' ),
'failed' => esc_html__( 'Failed', 'elasticpress' ),
'errors' => esc_html__( 'Errors', 'elasticpress' ),
'method' => esc_html__( 'Method', 'elasticpress' ),
'is_full_sync' => esc_html__( 'Full Sync', 'elasticpress' ),
'end_date_time' => esc_html__( 'End Date Time', 'elasticpress' ),
'start_date_time' => esc_html__( 'Start Date Time', 'elasticpress' ),
'total_time' => esc_html__( 'Total Time', 'elasticpress' ),
Expand All @@ -90,7 +95,7 @@ public function get_groups() : array {
* the usual `array_replace(array_flip())` strategy to reorder an array adds a wrong numeric value to the
* non-existent row.
*/
$preferred_order = [ 'method', 'start_date_time', 'end_date_time', 'total_time', 'total', 'synced', 'skipped', 'failed', 'errors' ];
$preferred_order = [ 'method', 'is_full_sync', 'start_date_time', 'end_date_time', 'total_time', 'total', 'synced', 'skipped', 'failed', 'errors' ];
$ordered_sync_info = [];
foreach ( $preferred_order as $field ) {
if ( array_key_exists( $field, $sync_info ) ) {
Expand Down
17 changes: 9 additions & 8 deletions tests/cypress/integration/general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ describe('WordPress can perform standard ElasticPress actions', { tags: '@slow'
cy.get('[aria-controls="health-check-accordion-block-ep-last-sync"]').click();
cy.get('#health-check-accordion-block-ep-last-sync .health-check-table').as('syncTable');
cy.get('@syncTable').get('tr:nth-child(1) td').should('contain.text', 'Method');
cy.get('@syncTable').get('tr:nth-child(2) td').should('contain.text', 'Start Date Time');
cy.get('@syncTable').get('tr:nth-child(3) td').should('contain.text', 'End Date Time');
cy.get('@syncTable').get('tr:nth-child(4) td').should('contain.text', 'Total Time');
cy.get('@syncTable').get('tr:nth-child(5) td').should('contain.text', 'Total');
cy.get('@syncTable').get('tr:nth-child(6) td').should('contain.text', 'Synced');
cy.get('@syncTable').get('tr:nth-child(7) td').should('contain.text', 'Skipped');
cy.get('@syncTable').get('tr:nth-child(8) td').should('contain.text', 'Failed');
cy.get('@syncTable').get('tr:nth-child(9) td').should('contain.text', 'Errors');
cy.get('@syncTable').get('tr:nth-child(2) td').should('contain.text', 'Full Sync');
cy.get('@syncTable').get('tr:nth-child(3) td').should('contain.text', 'Start Date Time');
cy.get('@syncTable').get('tr:nth-child(4) td').should('contain.text', 'End Date Time');
cy.get('@syncTable').get('tr:nth-child(5) td').should('contain.text', 'Total Time');
cy.get('@syncTable').get('tr:nth-child(6) td').should('contain.text', 'Total');
cy.get('@syncTable').get('tr:nth-child(7) td').should('contain.text', 'Synced');
cy.get('@syncTable').get('tr:nth-child(8) td').should('contain.text', 'Skipped');
cy.get('@syncTable').get('tr:nth-child(9) td').should('contain.text', 'Failed');
cy.get('@syncTable').get('tr:nth-child(10) td').should('contain.text', 'Errors');
});
});