Optimize Search, Filter State, and Growth Visualizations#247
Merged
Conversation
Add a missing useEffect in DiveSites.jsx to sync the local filters state with debouncedSearchTerms. This ensures that any typing in the search input debounces correctly and triggers React Query to fetch updated dive sites from the backend API, resolving the bug where only character-level fuzzy fallback suggestions were displayed.
Standardize search debouncing intervals to 500ms across all pages, and implement clean URL routing and state persistence for dive trips and routes. Update backend fuzzy-matching logic to support true relevance score sorting by default, and dynamically hide rating options on the frontend when reviews are disabled.
Add a searchable Owner/Creator filter to the dive sites listing page utilizing the UserSearchDropdown. Refactor UserSearchDropdown to pass the full user object so that filter states on both dives and dive sites can correctly capture and persist selection. Standardize and Map fields to the backend's native created_by_username parameter, and ensure the query parameter cleanly populates the search input on load without exposing redundant ID fields in the URL.
- Add 'users' field to GrowthDataResponse and GrowthRatesResponse schemas. - Implement users cumulative count querying and growth rate calculation inside get_growth_data system router. - Define a beautiful rose/red color scheme for users inside CHART_COLORS and render the User Growth chart at the top of the admin growth visualizations page.
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
This pull request introduces comprehensive optimizations, state debouncing, and consistency fixes across the Divemap search pages, introduces a new user-growth analytics chart to the admin dashboard, and implements a searchable Owner/Creator filter for dive sites.
🛠️ Changes Made
🔍 1. Search Debouncing & state Harmonization (All Listing Pages)
/dive-sites: Fixed a dead state hook where typing would never updatedebouncedSearchTerms. Introduced a correct debounceduseEffectthat synchronizes search and metadata inputs 500ms after typing pauses, triggering clean React Query fetches to the backend./diving-centers: Added proper debounce state updates, replacing immediate API queries on every single keystroke./dive-routes: AddeddebouncedSearchstate and synced query triggers. Removed default sort parameters from cluttering the active URL string./dive-trips: Added complete URL-state persistence and query parameters sync, making trip search states fully copy-paste friendly./dives: Unified search debounce interval to500msfor seamless cross-page snappiness.🌟 2. Relevance-based Matching & Dynamic Sorting Fallback (Backend & Frontend)
/dive-sites&/diving-centers): Updated backend controllers to calculate real phrase-aware matching scores for exact database results. In active searches, the engine now automatically falls back to relevance score descending by default (instead of sorting alphabetically by name). This ensures 100% exact matches consistently rank first./diving-centers): Configured the frontendsortOptionsto monitor whether center reviews are enabled, dynamically hiding the "Rating" sorting choice from the UI when disabled, while preserving clean400 Bad RequestAPI validation on the backend.👤 3. New Owner/Creator Filters (
/dive-sites&/dives)UserSearchDropdowninput.UserSearchDropdownto propagate full user objects down so caller elements on both/divesand/dive-sitescorrectly resolve selection IDs and username details.?created_by_username=admincleanly initializes and displays the search text without URL clutter.📈 4. Admin User Growth Visualizations (
/admin/growth-visualizations)🧪 Testing
Manual Verification
All changes were thoroughly tested in a live browser session using Chrome DevTools:
/diving-centersor/dive-sitesdisplays the correct autocomplete results with accurate highlight matches instantly."Kalymnos"or"Naxos"correctly ranks 100% matches first.Automated Tests
make lint-frontend— Passed with 0 errors/warnings.📌 Related Issues
/dive-sites./dive-sitesand broken mapping on/dives.