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 command stats and status #2290

Merged
merged 4 commits into from
Aug 9, 2021
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
Prev Previous commit
Next Next commit
Refactor to use wp_list_pluck
  • Loading branch information
Rahmon committed Aug 5, 2021
commit 0f7ea08bb9af0fe6b4bc62cca4022e78acc0cb09
24 changes: 2 additions & 22 deletions includes/classes/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1119,17 +1119,7 @@ public function status() {
$indexes_from_cat_indices_api = json_decode( wp_remote_retrieve_body( $response_cat_indices ), true );

if ( is_array( $indexes_from_cat_indices_api ) ) {
$indexes_from_cat_indices_api = array_reduce(
$indexes_from_cat_indices_api,
function( $carry, $item ) {
if ( ! empty( $item['index'] ) ) {
$carry[] = $item['index'];
}

return $carry;
},
[]
);
$indexes_from_cat_indices_api = wp_list_pluck( $indexes_from_cat_indices_api, 'index' );

$index_names = array_intersect( $index_names, $indexes_from_cat_indices_api );
} else {
Expand Down Expand Up @@ -1191,17 +1181,7 @@ public function stats() {
$indexes_from_cat_indices_api = json_decode( wp_remote_retrieve_body( $response_cat_indices ), true );

if ( is_array( $indexes_from_cat_indices_api ) ) {
$indexes_from_cat_indices_api = array_reduce(
$indexes_from_cat_indices_api,
function( $carry, $item ) {
if ( ! empty( $item['index'] ) ) {
$carry[] = $item['index'];
}

return $carry;
},
[]
);
$indexes_from_cat_indices_api = wp_list_pluck( $indexes_from_cat_indices_api, 'index' );

$index_names = array_intersect( $index_names, $indexes_from_cat_indices_api );
} else {
Expand Down