Skip to content

Optimize Search, Filter State, and Growth Visualizations#247

Merged
kargig merged 4 commits into
mainfrom
feature/dive-site-search-debouncing
Jun 15, 2026
Merged

Optimize Search, Filter State, and Growth Visualizations#247
kargig merged 4 commits into
mainfrom
feature/dive-site-search-debouncing

Conversation

@kargig

@kargig kargig commented Jun 15, 2026

Copy link
Copy Markdown
Owner

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 update debouncedSearchTerms. Introduced a correct debounced useEffect that 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: Added debouncedSearch state 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 to 500ms for seamless cross-page snappiness.

🌟 2. Relevance-based Matching & Dynamic Sorting Fallback (Backend & Frontend)

  • Relevance Fallback (/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.
  • Settings-Driven UI Filtering (/diving-centers): Configured the frontend sortOptions to monitor whether center reviews are enabled, dynamically hiding the "Rating" sorting choice from the UI when disabled, while preserving clean 400 Bad Request API validation on the backend.

👤 3. New Owner/Creator Filters (/dive-sites & /dives)

  • Added searchable "Owner/Creator" filters to both layouts using the UserSearchDropdown input.
  • Refactored UserSearchDropdown to propagate full user objects down so caller elements on both /dives and /dive-sites correctly resolve selection IDs and username details.
  • Implemented clean query parameter sync so visiting ?created_by_username=admin cleanly initializes and displays the search text without URL clutter.

📈 4. Admin User Growth Visualizations (/admin/growth-visualizations)

  • Added a new "User Growth" area-spline chart utilizing Pydantic growth schemas and daily/weekly cumulative counting in the backend system router.
  • Integrated the rose-pink color scheme for User Growth, rendering it at the top of the growth dashboard.

🧪 Testing

Manual Verification

All changes were thoroughly tested in a live browser session using Chrome DevTools:

  • Dropdown Autocomplete: Verified that typing in /diving-centers or /dive-sites displays the correct autocomplete results with accurate highlight matches instantly.
  • Relevance Ranking: Verified searching "Kalymnos" or "Naxos" correctly ranks 100% matches first.
  • URL Persistence: Confirmed filters and searches elegantly sync with browser address bar state.
  • Admin Verification: Confirmed that the admin-level User Growth chart displays correct cumulative numbers and percentage rates over 1-week, 1-month, 3-month, 6-month, and 1-year intervals.

Automated Tests

  • Ran make lint-frontendPassed with 0 errors/warnings.
  • Executed the integration test suite — All main page tests passed with 0 errors.

📌 Related Issues

  • Resolves the broken autocomplete search on /dive-sites.
  • Resolves alphabetical sort override bug on active searches.
  • Resolves missing "User/Owner" filter on /dive-sites and broken mapping on /dives.
  • Implements the requested Admin User Growth visualization card.

kargig added 4 commits June 15, 2026 23:00
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.
@kargig kargig merged commit c4f2679 into main Jun 15, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant