feat: add hour_of_day_range, swell_height, and wind_direction notification filters#8
Open
jsauca wants to merge 2 commits into
Open
feat: add hour_of_day_range, swell_height, and wind_direction notification filters#8jsauca wants to merge 2 commits into
jsauca wants to merge 2 commits into
Conversation
New filter type lets users restrict alerts to a specific hour-of-day window (e.g. only between 10h and 14h). To make the window meaningful, the rule engine now scans all 24 hours of each day and reports matching hours instead of evaluating once against daily averages. - Migration extends the notification_rules type CHECK with 'hour_of_day_range' (value stored as "<start>-<end>", inclusive, Paris-local hours 0-23, no wrap-around). - Rule engine adds an `hour` field to ComputedConditions and a new evaluateRulesAcrossDay() that returns matched + matchingHours. Mirrored in both src/lib/notifications/rule-engine.ts (client) and supabase/functions/_shared/scoring.ts (edge). - buildHourlyConditions() produces 24 per-hour snapshots reusing the existing computeTidePhase. Wind/cloud are per-hour; species scores, global score, coefficient and pressure trend stay day-level and are broadcast across the snapshots. - notify-morning and notify-evening switch from daily evaluation to the hourly scan. Push body now reports the matching window via a formatWindow helper that collapses contiguous hours. - UI: new "Plage horaire" type with two number inputs (0-23), saved as "<start>-<end>"; ruleLabel renders e.g. "Plage horaire 10h–15h". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two new rule types for the notification filter: - swell_height (numeric, meters) — fetched from Open-Meteo marine API using Biscarrosse-Plage as an open-Atlantic proxy, since the Arcachon zone coords get snapped to a sheltered bay grid cell - wind_direction — multi-select of 8 cardinal sectors (N/NE/E/SE/S/SO/O/NO), stored as comma-separated codes; the engine buckets the actual wind degrees into the nearest 45° sector Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@jsauca is attempting to deploy a commit to the baptistelac's projects Team on Vercel. A member of the Team first needs to authorize it. |
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
Three new rule types for the
/moi/notificationsfilter, building on the existingcloud_cover/tide_phase/ etc. patterns:hour_of_day_range— restrict alerts to a daily window (e.g.10h–14h). Stored asstart-end(0–23, inclusive).swell_height— numeric meters with operator (≤/≥/</>). Fetched from the Open-Meteo marine API. Uses Biscarrosse-Plage coords (44.43, -1.25) as an open-Atlantic proxy — the Arcachon zone gets snapped to a sheltered bay grid cell, while Biscarrosse gives a representative reading for boats heading out the Cap Ferret pass.wind_direction— multi-select of 8 cardinal sectors (N / NE / E / SE / S / SO / O / NO). Stored as comma-separated codes; the engine buckets the actual wind degrees into the nearest 45° sector and checks set membership.Touch points
notification_rules.typeCHECK constraintsrc/lib/notifications/rule-engine.ts+supabase/functions/_shared/scoring.ts) — added types,degreesToCardinal8helper, evaluation branches, extendedComputedConditionsandbuildHourlyConditionssignaturenotify-morning,notify-evening) — addedwind_direction_10mto the existing forecast call (free) + new marine fetch with graceful fallback if the marine API failsNotificationsClient.tsx) — new labels, swell numeric input withmsuffix, wind direction 4-col chip multi-select, validation, ruleLabel displayrule-engine.test.tscovering both new rule types + the helperTest plan
npm test -- rule-engine→ 42/42 passnpx tsc --noEmit→ cleansupabase db push(or via dashboard)supabase functions deploy notify-morning notify-evening/moi/notifications:Houle ≤ 1.0 mrule — appears with correct labelDirection du vent — N, NOrule — multi-select chips toggle, label reads "Vent venant de N, NO"Plage horaire 10h–14hrule — boundaries inclusivewind_directionwith no sector selected — error shown, no insert🤖 Generated with Claude Code