Skip to content

Marine Weather Integration and Mobile UX Enhancements#171

Merged
kargig merged 5 commits intomainfrom
feature/marine_api
Jan 25, 2026
Merged

Marine Weather Integration and Mobile UX Enhancements#171
kargig merged 5 commits intomainfrom
feature/marine_api

Conversation

@kargig
Copy link
Owner

@kargig kargig commented Jan 25, 2026

Summary

This PR significantly enhances the application's weather data capabilities by integrating the Open-Meteo Marine API and provides several mobile user experience improvements. It also includes a fix for the Subsurface XML import process and various security refactorings.

Changes Made

New Features & Enhancements

  • Marine Weather API Integration: Integrated the Open-Meteo Marine API to fetch real-time wave height, direction, and period.
  • Enhanced Suitability Logic: Updated the dive site suitability engine to incorporate marine conditions (wave period and height) into the safety and quality calculations.
  • Mobile UX Improvements:
    • Implemented a sticky search bar for easier navigation on small screens.
    • Improved menu readability and interaction patterns for touch devices.

Additional Improvements & Fixes

  • Ghost Cylinder Fix: Modified the Subsurface XML import logic in backend/app/routers/dives/dives_import.py to filter out invalid/empty "ghost" cylinders that appeared in certain XML exports.
  • Security & Refactoring:
    • Addressed security vulnerabilities in authentication and weather service layers.
    • Updated frontend tests to maintain compatibility with the latest component standards.

Testing

Automated Testing

  • New Unit Tests: Added backend/tests/test_dive_import_utils.py to ensure robust parsing of cylinder data and prevent regression of the ghost tank bug.
  • Full Suite Verification: Executed all backend integration tests using ./docker-test-github-actions.sh, confirming stability across weather and dive logging modules.

Manual Testing

  • Verified Marine API data display on dive site detail pages.
  • Performed mobile responsiveness testing on multiple viewport sizes.

Related Issues

  • Enhances environmental data accuracy for dive site suitability.
  • Resolves mobile navigation friction points.

Additional Notes

  • The addition of marine data may require a one-time cache warmup for popular dive sites.

Enhance the Open-Meteo service to fetch marine weather data (wave height,
direction, period, swell, SST, and sea level) in parallel with wind
data.

Changes:
- Add `OPEN_METEO_MARINE_URL` constant
- Update `fetch_wind_data_single_point` to fetch and merge marine data
- Update `fetch_wind_data_grid` to batch fetch marine data
- Update tests to reflect the new dual-API call behavior (Wind + Marine)

This enables the frontend to display comprehensive marine conditions
without requiring additional scheduled tasks or database schema changes,
leveraging the existing 3-tier caching infrastructure.
- Backend: Fetch marine data (wave height, period, direction, swell, SST) from Open-Meteo in addition to wind.
- Service: Enhance `calculate_wind_suitability` to consider wave height and period. High waves (>1.5m) or surge now trigger "Avoid" or "Difficult" ratings independent of wind.
- API: Update `get_wind_recommendations` and `get_wind_data` endpoints to return full marine datasets.
- Frontend: Add `MarineConditionsCard` component with tabs for Wind and Marine data.
- UI: Update map popups (DiveSitesMap, LeafletMapView, WindOverlay) to display wave and water temperature data under "Weather & Sea Conditions".
- UI: Implement lazy loading via Ant Design `Collapse` for "Current Weather Conditions" and "Nearby Dive Sites" on the Dive Site Detail page to improve performance.
- Docs: Update Wind Overlay Legend to explain new marine-based suitability criteria.
- Update `NavbarMobileControls` to force white text color for sub-menu items (Dive Log, Dive Sites, etc.), fixing contrast issues where items appeared disabled.
- Update `ResponsiveFilterBar` to use sticky positioning for the search and filter bar, ensuring they remain accessible while scrolling.
- Refactor `useResponsive` hook to refine scroll detection logic, adding a delay before hiding the search bar on scroll up to prevent flickering during interaction.
- Ensure `DiveSites` page always renders the filter bar to support the sticky behavior.
…n v6

Security Fixes:
- Implement chunked file reading for dive site photo uploads in backend
  to prevent Memory Exhaustion DoS (CVE-like pattern).
- Integrate DOMPurify in frontend to sanitize map popup content in:
  - DiveSitesMap.js
  - LeafletMapView.js
  - DivesMap.js
  - DivingCentersMap.js
  This mitigates potential Stored XSS vulnerabilities in all map components.

Frontend Refactoring (Ant Design v6 Migration):
- Refactor Help and Changelog pages to adhere to latest naming conventions:
  - Replace `Steps` children with `items` prop.
  - Update `Space` `direction` -> `orientation`.
  - Update `Divider` `type` -> `orientation`.
  - Update `Card` `bodyStyle` -> `styles.body`.
- Fix linting errors in DiveSites.js.

Test & Compatibility Updates:
- Update backend weather API tests to correctly verify parameters across
  multiple concurrent service calls (Wind + Marine data).
- Update frontend calculator test expectations (BestMix, Mod, MinGas,
  GasPlanning) to align with precise physics calculations using
  Standard Surface Pressure (1.01325 bar) and Real Gas Law (Z-Factor).

Verification:
- Backend: All 1339 tests passed.
- Frontend: All unit tests passed.
- Filter out invalid cylinders in `create_structured_gas_data` that lack size, pressure, gas mix, or valid description.
- Prevent creation of "Stage 2" ghost tanks (often "unknown" description in XML) when importing Subsurface logs.
- Add regression tests in `backend/tests/test_dive_import_utils.py`.
@kargig kargig merged commit 49b5925 into main Jan 25, 2026
2 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