Add availability index for efficient timeframe queries#24
Open
datengraben wants to merge 1 commit into
Open
Conversation
Introduces three new MySQL tables (cb_availability_index, cb_timeframe_locations, cb_timeframe_items) that index timeframe date ranges and their many-to-many location/item relationships, replacing LIKE-on-serialised-array scans with indexed integer JOINs. Write-side sync is wired into wp_insert_post (priority 12, after manageTimeframeMeta at 11), before_delete_post, wp_trash_post, untrash_post, and location/item hard-deletion hooks. The updateAllTimeframes() path (triggered when a location or item is added/renamed/deleted) also re-upserts affected holiday/repair timeframes. A paginated AJAX upgrade task backfills existing posts. https://claude.ai/code/session_01ECQBUo5Q5HHzuinoWerH8g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces a new availability index system to enable efficient querying of timeframes by location, item, and date range. This addresses performance concerns when checking availability across multiple dimensions.
Key Changes
New
AvailabilityIndexrepository class (src/Repository/AvailabilityIndex.php):cb_availability_index(main index),cb_timeframe_locations(location junction), andcb_timeframe_items(item junction)upsertTimeframe()to insert/update index entries with validation (type checking, status filtering, location/item requirements)getByLocationAndItemAndDateRange()for efficient range queries with optional type and status filteringdeleteByTimeframeId(),removeLocation(),removeItem()rebuildFromAllTimeframes()for paginated index rebuilding during upgradesPlugin activation and lifecycle hooks (
src/Plugin.php):wp_insert_posthook (priority 12)Timeframe batch updates (
src/Wordpress/CustomPostType/Timeframe.php):updateAllTimeframes()to sync index entries for bulk operationsUpgrade system integration (
src/Service/Upgrade.php):rebuildFromAllTimeframes()as a paginated upgrade task for version 2.11.0Implementation Details
https://claude.ai/code/session_01ECQBUo5Q5HHzuinoWerH8g