Skip to content

Commit

Permalink
Update Qualitative Feedback note to have more efficient sql query (#7825
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jessepearson authored Dec 12, 2023
1 parent d04bda8 commit 3d373d6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-3693-qualitative-feedback-note
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Update Qualitative Feedback note to have more efficient sql query.
23 changes: 21 additions & 2 deletions includes/notes/class-wc-payments-notes-qualitative-feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,27 @@ public static function get_note() {
}

// We should have at least one transaction.
$token_count = $wpdb->get_var( "select count(*) from {$wpdb->prefix}woocommerce_payment_tokens" );
if ( 0 === (int) $token_count ) {
if ( WC_Payments_Utils::is_hpos_tables_usage_enabled() ) {
$result = $wpdb->get_var(
"SELECT EXISTS(
SELECT 1
FROM {$wpdb->prefix}wc_orders_meta
WHERE meta_key = '_wcpay_transaction_fee'
LIMIT 1)
AS count;"
);
} else {
$result = $wpdb->get_var(
"SELECT EXISTS(
SELECT 1
FROM {$wpdb->postmeta}
WHERE meta_key = '_wcpay_transaction_fee'
LIMIT 1)
AS count;"
);
}

if ( 1 !== intval( $result ) ) {
return;
}

Expand Down

0 comments on commit 3d373d6

Please sign in to comment.