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

Fix/cli offset #2591

Merged
merged 4 commits into from
Feb 22, 2022
Merged
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
27 changes: 23 additions & 4 deletions includes/classes/IndexHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,11 @@ protected function index_objects() {
$this->temporary_wp_actions = $wp_actions;

$this->current_query = $this->get_objects_to_index();
$is_offsetting = 0 !== $this->index_meta['offset'];

$this->index_meta['found_items'] = (int) $this->current_query['total_objects'];

$this->index_meta['from'] = $is_offsetting ? $this->index_meta['offset'] : 1;
$this->index_meta['show_skip_message'] = $is_offsetting && ! isset( $this->index_meta['show_skip_message'] );
$this->index_meta['found_items'] = (int) $this->current_query['total_objects'];
$this->index_meta['current_sync_item']['total'] = $this->index_meta['found_items'];

if ( $this->index_meta['found_items'] && $this->index_meta['offset'] < $this->index_meta['found_items'] ) {
Expand Down Expand Up @@ -648,10 +650,27 @@ function( $item ) {
}
}

if ( isset( $this->index_meta['show_skip_message'] ) && $this->index_meta['show_skip_message'] ) {
$this->output(
sprintf(
/* translators: 1. Number of objects skipped 2. Indexable type */
esc_html__( 'Skipping %1$d %2$s...', 'elasticpress' ),
$this->index_meta['from'],
esc_html( strtolower( $indexable->labels['plural'] ) )
),
'info',
'index_next_batch'
);

$this->index_meta['show_skip_message'] = false;
}

$this->output(
sprintf(
/* translators: 1. Number of objects indexed, 2. Total number of objects, 3. Last object ID */
esc_html__( 'Processed %1$d/%2$d. Last Object ID: %3$d', 'elasticpress' ),
/* translators: 1. Indexable type 2. Offset start, 3. Offset end, 4. Found items 5. Last object ID */
esc_html__( 'Processed %1$s %2$d - %3$d of %4$d. Last Object ID: %5$d', 'elasticpress' ),
esc_html( strtolower( $indexable->labels['plural'] ) ),
$this->index_meta['from'],
$this->index_meta['offset'],
$this->index_meta['found_items'],
$this->index_meta['current_sync_item']['last_processed_object_id']
Expand Down