Skip to content

Commit

Permalink
Aggregate different errors by type
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeelia committed Sep 28, 2023
1 parent 97aafe8 commit 6f58ffd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions includes/classes/IndexHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1481,11 +1481,20 @@ protected function build_message_errors_data( $messages ) : array {
$messages = (array) $messages;
$error_interpreter = new \ElasticPress\ElasticsearchErrorInterpreter();

$errors_data = [];
$errors_list = [];
foreach ( $messages as $message ) {
$errors_data[] = $error_interpreter->maybe_suggest_solution_for_es( $message );
$error = $error_interpreter->maybe_suggest_solution_for_es( $message );

if ( ! isset( $errors_list[ $error['error'] ] ) ) {
$errors_list[ $error['error'] ] = [
'solution' => $error['solution'],
'count' => 1,
];
} else {
$errors_list[ $error['error'] ]['count']++;
}
}
return $errors_data;
return $errors_list;
}

/**
Expand Down

0 comments on commit 6f58ffd

Please sign in to comment.