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 1 commit
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
26 changes: 25 additions & 1 deletion includes/classes/IndexHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,34 @@ function( $item ) {
}
}

$from = $this->index_meta['offset'] - count( $this->current_query['objects'] );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of placing this entire code inside of index_next_batch(), wouldn't it be better to add it to index_objects(), right before we actually start indexing things?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @felipeelia I've moved this code here: 993fe3b


if ( 0 !== $from && empty( $this->index_meta['skip_message_shown'] ) ) {
$this->output(
sprintf(
/* translators: 1. Number of objects indexed */
esc_html__( 'Skipping %1$d %2$s posts...', 'elasticpress' ),
$from,
esc_html( strtolower( $indexable->labels['plural'] ) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oscarssanchez a few things in this block:

  1. The "translators" comment should be aligned with the esc_html__ call (an example here)
  2. It is missing the second placeholder description
  3. If I'm reading this right, the %2$s will become "posts", "users", etc., right? If so, won't it become Skipping 100 posts posts... (duplicated posts)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @felipeelia thanks i've fixed here a95e35d and here cf7cf41

),
'info',
'index_next_batch'
);
}

// From can never actually be 0, as we can't process post number 0.
if ( 0 === $from ) {
$from = 1;
}

$this->index_meta['skip_message_shown'] = true;

$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' ),
esc_html__( 'Processed %1$s %2$d - %3$d of %4$d. Last Object ID: %5$d', 'elasticpress' ),
esc_html( strtolower( $indexable->labels['plural'] ) ),
$from,
$this->index_meta['offset'],
$this->index_meta['found_items'],
$this->index_meta['current_sync_item']['last_processed_object_id']
Expand Down