-
Notifications
You must be signed in to change notification settings - Fork 1
feat: koko command #76
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
composer.lockClick to show 74 changes in this composer.lock fileDev Package changes
Settings · Docs · Powered by Private Packagist |
cmurtagh
approved these changes
Nov 18, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: https://github.com/pressbooks/private/issues/2026
If this WP CLI command works, we should delete the script defined in https://github.com/pressbooks/pressbooks-network-analytics/pull/411 to avoid redundancy.
This pull request introduces a new WP-CLI command,
pb network-aggregate, for aggregating Koko Analytics data across a Pressbooks multisite network. It adds robust batching, retry, and failure management to handle large networks and persistent errors gracefully. The implementation includes a distributed locking mechanism to prevent concurrent runs and records failures with exponential backoff for later retry. The changes also ensure plugin conflicts are avoided during aggregation by skipping problematic plugins.New command and documentation:
pb network-aggregateWP-CLI command, including detailed documentation inREADME.mdabout its options, behavior, troubleshooting, and internal logic. [1] [2] [3]Aggregation and batching logic:
NetworkAggregateCommand, with batching, retries, start/max site controls, and Slack notification integration for reporting results.Runner,AggregatorService, andBlogRepositoryclasses to manage batch processing, aggregation logic, and efficient blog selection using keyset pagination. [1] [2] [3]Failure handling and backoff:
FailureRepositoryandBackoffStrategyclasses to record failures, schedule retries with exponential backoff, and clear records on success. [1] [2]Distributed locking and logging:
LockManagerfor MySQL advisory locking to prevent concurrent aggregations, andCliLoggerfor structured CLI output. [1] [2]Plugin conflict avoidance:
command.phpto automatically skip plugins known to cause Mustache conflicts when running the aggregation command, ensuring reliable execution.Testing case
For testing, you can try:
wp pb network-aggregate --mode=both --batch-size=200 --path=<WP_INSTALLATION_PATH>