Skip to content

Commit

Permalink
Merge pull request #21711 from Yoast/296-add-additional-data-to-the-s…
Browse files Browse the repository at this point in the history
…emrush-call-in-semrush-phrases-actionphp-63-phnqtdinkd

Add columns to the semrush api request
  • Loading branch information
thijsoo authored Oct 28, 2024
2 parents 770c2d5 + 08b3b2b commit a42aa9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/actions/semrush/semrush-phrases-action.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public function get_related_keyphrases( $keyphrase, $database ) {
$transient_key = \sprintf( static::TRANSIENT_CACHE_KEY, $keyphrase, $database );
$transient = \get_transient( $transient_key );

if ( $transient !== false ) {
if ( $transient !== false && isset( $transient['data']['columnNames'] ) && \count( $transient['data']['columnNames'] ) === 5 ) {
return $this->to_result_object( $transient );
}

$options = [
'params' => [
'phrase' => $keyphrase,
'database' => $database,
'export_columns' => 'Ph,Nq,Td',
'export_columns' => 'Ph,Nq,Td,In,Kd',
'display_limit' => 10,
'display_offset' => 0,
'display_sort' => 'nq_desc',
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Actions/SEMrush/SEMrush_Phrases_Action_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function test_get_related_keyphrases_from_api() {
'params' => [
'phrase' => $keyphrase,
'database' => $country_code,
'export_columns' => 'Ph,Nq,Td',
'export_columns' => 'Ph,Nq,Td,In,Kd',
'display_limit' => 10,
'display_offset' => 0,
'display_sort' => 'nq_desc',
Expand Down Expand Up @@ -131,8 +131,8 @@ public function test_get_related_keyphrases_from_cache() {
->andReturn(
[
'data' => [
'column_names' => [],
'rows' => [],
'columnNames' => [ 'Ph', 'Nq', 'Td', 'In', 'Kd' ],
'rows' => [],
],
'status' => 200,
]
Expand All @@ -145,8 +145,8 @@ public function test_get_related_keyphrases_from_cache() {
$this->assertEquals(
(object) [
'results' => [
'column_names' => [],
'rows' => [],
'columnNames' => [ 'Ph', 'Nq', 'Td', 'In', 'Kd' ],
'rows' => [],
],
'status' => 200,
],
Expand Down

0 comments on commit a42aa9a

Please sign in to comment.