Skip to content

Conversation

@graham73may
Copy link
Contributor

Sorry for the new PR, I couldn't contribute to the original PR and wanted to contribute in a way that provided a mergeable update.


I've taken a look at BramDriesen's work in #24 but ran in to a couple of issues.

  1. Renamed the command for consistency with core (commit)

wp batch-processing {enter_your_batch_id}

  1. Function get_all_items() doesn't seem to exist in /includes/class-batch.php. I have made $items public and adjusted class-wp-cli.php accordingly. (commit)

I've opted for making $items public instead of adding the missing get_all_items() function, I wasn't sure if this was missing from the original PR or was removed from the main plugin at some point. Making the property public seemed to be a low risk option with minimal code changes.


I believe this PR is mergeable, but having used it some QoL additions would be to include a command to:

  1. List available batches
  2. Restart a batch

@graham73may
Copy link
Contributor Author

I've added the subcommands I mentioned in my original message.

Running wp help batch-process now gives:

NAME

  wp batch-process

DESCRIPTION

  Class Batch_Processor_CLI_Command().

SYNOPSIS

  wp batch-process <command>

SUBCOMMANDS

  list         List all registered batches.
  process      Process a registered batch by ID.
  restart      Restart a registered batch by ID.

wp batch-process process batch_name_one

Starting processing batch: batch_name_one with 6 items
Processing batch items  100% [=================================================================================================================================================================================] 0:03 / 0:03

wp batch-process list

wp batch-process list
+--------------------+-------+-----------+------------+----------+
| ID                 | Total | Processed | Percentage | Finished |
+--------------------+-------+-----------+------------+----------+
| batch_name_one     | 6     | 6         | 100.00%    | Yes      |
| batch_name_two     | 0     | 0         | 0.00%      | Yes      |
+--------------------+-------+-----------+------------+----------+

wp batch-process restart {batch_id_here}

wp batch-process restart batch_name_one
Success: Batch 'batch_name_one' restarted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants