perf(2meet-data-optimizer-hivepress-addon): index the numeric listing columns HivePress filters and sorts on
- hp_listing_core declares indexes on hp_hourly_rate and hp_rating_count; core adds them in place (WP-CLI / WP-Cron), the pinned schema hash is unchanged - Verify: unit 145, integration 52, phpcs; dev36 902k listings (SHOW INDEX, EXPLAIN) - PR: PR-090
This commit is contained in:
@@ -257,7 +257,16 @@ final class TMDO_HivePress_Entity_Groups {
|
||||
'label' => 'Hourly rate',
|
||||
),
|
||||
),
|
||||
array( 'post_types' => array( 'hp_listing' ) )
|
||||
array(
|
||||
'post_types' => array( 'hp_listing' ),
|
||||
// Filtered and sorted on by HivePress search. Declared as indexes
|
||||
// (added in place) rather than `searchable`, which would change
|
||||
// the schema hash and rebuild a table that may hold aeav_only data.
|
||||
'indexes' => array(
|
||||
'hourly_rate' => array( 'hp_hourly_rate' ),
|
||||
'rating_count' => array( 'hp_rating_count' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -58,6 +58,21 @@ class HivePressEntityGroupsTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HivePress filters and sorts listings by these; they are declared as
|
||||
* group indexes (added in place by core) rather than `searchable`, which
|
||||
* would change the pinned hash and rebuild the table.
|
||||
*/
|
||||
public function test_listing_columns_filtered_and_sorted_on_are_indexed(): void {
|
||||
$this->assertSame(
|
||||
array(
|
||||
'hourly_rate' => array( 'hp_hourly_rate' ),
|
||||
'rating_count' => array( 'hp_rating_count' ),
|
||||
),
|
||||
TMDO_Entity_Registry::get_group_indexes( 'post', 'hp_listing_core' )
|
||||
);
|
||||
}
|
||||
|
||||
public function test_shared_keys_keep_their_current_owner(): void {
|
||||
foreach ( self::SHARED_KEY_OWNERS as $key => $group ) {
|
||||
$this->assertSame( $group, TMDO_Entity_Registry::get_field( 'post', $key )['group'], $key );
|
||||
|
||||
Reference in New Issue
Block a user