Filter past events out of the homepage carousel - #402
Open
seandavi wants to merge 1 commit into
Open
Conversation
top_events() sorted events by start date and took the last five with no date filter, so the homepage advertised conferences that had already finished (currently including EuroBioC2025). Its siblings upcoming_events() and previous_events() both filter on e[:end]; this one did not. Apply the same filter, and switch sorted[-5..-1] to last(5): the slice returns nil when fewer than five elements remain, which the filter now makes reachable. Fixes #401 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YBSvPwEk6sH1rhGmjPmsFq
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.
Fixes #401.
top_events()(lib/helpers.rb:452) sorted events by start date and took the last five, with no date filter — so the homepage carousel showed the five chronologically-latest events whether or not they had already happened. Its two siblings both filter correctly:upcoming_events()at:426andprevious_events()at:446each teste[:end]against today.This applies the same filter.
Why
last(5)instead of keeping[-5..-1]sorted[-5..-1]returnsnilwhen the array holds fewer than five elements, andnil.reverseraises. That was latent before (it needed the site to have fewer than five events total) but the filter makes it reachable — any period with fewer than five upcoming events would hit it.last(5)returns what it has.Verification
Ran the before/after logic against synthetic events (3 past, 2 upcoming) on Ruby 3.2:
The old path leaks all three past events; the new one returns only upcoming, newest first, and the
nilhazard is confirmed real rather than theoretical.I was not able to run a full site build to check this end to end — no Ruby toolchain for this repo locally, and the pinned Ruby 2.6.5 / Debian Buster image is awkward to stand up. The change is confined to one function whose only caller is
layouts/components/homepage/events.html, so the blast radius is the homepage carousel.Note for reviewers
With the filter applied, the carousel will show fewer than five entries when fewer than five events are upcoming. That seemed clearly preferable to backfilling with finished events, but if the design wants exactly five slots filled, that's a different fix and worth saying so.
🤖 Generated with Claude Code
https://claude.ai/code/session_01YBSvPwEk6sH1rhGmjPmsFq