Don't show the featured event layout without race-day weather#360
Merged
Conversation
The featured window (is_close?, owner timezone) and the weather-fetch window (days_until, the event's own geocoded timezone) can disagree at the 10-day boundary, so an event could get the featured treatment (expanded card + a 'Race Day Weather' heading) while no forecast was ever fetched — leaving an empty weather block for an event effectively more than 10 days out. Demote such an event to a regular upcoming race when the forecast is missing, and trim the list back to the non-featured count. Today's race keeps its own section regardless. Also pass the rendered list size and featured flag to event_collection_variant so the layout class matches what the controller actually decided.
✅ Deploy Preview for giventotri canceled.
|
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.
Problem
The featured event was getting the expanded "featured" treatment (bigger card + a Race Day Weather heading) even when it was effectively more than 10 days out, leaving an empty weather block.
The cause is two different 10-day windows:
is_featured?→is_close?) checks the window in the owner's current-location timezone.event_weather_for) computesdays_untilin the event's own geocoded timezone and only fetches a forecast whendays_until.between?(0, 10).At the 10-day boundary these disagree, so an event can be flagged "featured" while no forecast was ever fetched. The
EventWeatherPresenteris still non-nil(the event has coordinates), so the inline_event_weatherpartial renders its "Race Day Weather" heading with no actual forecast underneath.Fix
EventsController#upcoming, when an upcoming (not-today) featured event has no forecast (@event_weather.forecastblank), demote it to a regular upcoming race: clear@featured/@event_weatherand trim the list back to the non-featured count of 3. Today's race keeps its own section regardless — it's race day.upcoming.html.erb, pass the rendered@upcoming.sizeand@featuredflag toevent_collection_variantso the collection layout class reflects what the controller actually decided (instead of re-deriving from the helper, which doesn't know about the demotion).Tests
Added a request spec: when the next race is within the featured window but
WeatherKitreturns no data, the response renders it as a plain upcoming race — nocollection--has-featured, noevent--is-featured, no "Race Day Weather" block. Full events spec passes (the 5 failingplausible_pageviewsspecs are pre-existing and unrelated).https://claude.ai/code/session_01LN8no8Vf2kqxcSGc4Ymyb8
Generated by Claude Code