Skip to content

Add rider sign-up date filter to search functionality#497

Open
neal-bpm wants to merge 3 commits into
mainfrom
vn/filter-rider-signed-up
Open

Add rider sign-up date filter to search functionality#497
neal-bpm wants to merge 3 commits into
mainfrom
vn/filter-rider-signed-up

Conversation

@neal-bpm
Copy link
Copy Markdown
Contributor

@neal-bpm neal-bpm commented May 7, 2026

Describe your changes

Implement a new "signed up" filter allowing users to search riders by signup timeframes (today, yesterday, week, month, year). Includes autocomplete suggestions and badge styling consistent with existing filters.

  • Add signed_up filter cases to RiderSearch module
  • Support explicit date boundaries for today/yesterday
  • Support relative time queries for week/month/year ranges
  • Add UI suggestions and autocomplete support
  • Add comprehensive test suite
  • Introduce signed_up_ago/2 helper for cleaner test code

Checklist before requesting a review

  • I have performed a self-review of my code
  • If it is a core feature, I have added tests.
  • Are there other PRs or Issues that I should link to here?
  • Will this be part of a product update? If yes, please write one phrase
    about this update in the description above.

Summary by cubic

Adds a "signed up" filter to rider search so you can find riders by signup timeframe (today, yesterday, week, month, year). Includes autocomplete suggestions, a "Signed Up" badge, and full test coverage.

  • New Features

    • New signed_up filter with values: today, yesterday, week, month, year.
    • Today/yesterday use exact UTC day boundaries; other ranges use relative windows.
    • Autocomplete suggestions, a "Signed Up" group with blue badge styling, and placeholder updated to include "signed up".
    • Tests for all timeframes plus a signed_up_ago/2 test helper.
    • Unknown signed_up values are ignored (no-op) to prevent errors.
  • Refactors

    • Render "Signed Up" suggestions using HEEx :for for simpler markup.

Written for commit 4e9e025. Summary will update on new commits.

Summary by CodeRabbit

Release Notes

  • New Features
    • Riders can now be filtered by sign-up date with preset time period options: today, yesterday, week, month, and year.
    • Search input placeholder updated to display all available filter hints, including the new sign-up date filter.

  Implement a new "signed up" filter allowing users to search riders by signup timeframes (today, yesterday, week, month, year). Includes autocomplete suggestions and badge styling consistent with existing filters.

  - Add signed_up filter cases to RiderSearch module
  - Support explicit date boundaries for today/yesterday
  - Support relative time queries for week/month/year ranges
  - Add UI suggestions and autocomplete support
  - Add comprehensive test suite
  - Introduce signed_up_ago/2 helper for cleaner test code
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a complete rider search filter for sign-up dates. Users can filter riders by when they joined using five time period options (today, yesterday, week, month, year). The backend applies date-based and relative-window queries, the frontend provides autocompleting filter suggestions, and comprehensive tests validate the filtering logic.

Changes

Signed Up Filter Feature

Layer / File(s) Summary
Suggestions Data Structure
lib/bike_brigade_web/live/rider_live/index.ex
Suggestions struct gained signed_up: [] field; @signed_ups filter source defines available time periods with labels.
Backend Query Logic
lib/bike_brigade/riders/rider_search.ex
New apply_filter/3 clauses for :signed_up filter: one computes UTC date boundaries for today/yesterday; another applies relative time windows for week/month/year.
Frontend Suggestion Logic
lib/bike_brigade_web/live/rider_live/index.ex
Suggestions.suggest/2 extended to clear signed_up on empty search, recognize signed_up:<value> facet patterns, and include full @signed_ups list in default free-text suggestions.
UI Rendering & Styling
lib/bike_brigade_web/live/rider_live/index.html.heex, lib/bike_brigade_web/live/rider_live/index.ex
Template renders "Signed Up" suggestion section when available; placeholder text updated with additional filter hints; color styling added for :signed_up filter type.
Tests & Helpers
test/bike_brigade/riders/rider_search_test.exs
New test suite for all five time periods with inclusion/exclusion validation; signed_up_ago/2 helper generates relative UTC timestamps.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A filter for the when-they-signed,
Time windows sorted, cleanly lined,
Today and week and month so bright,
Suggestions flowing left and right,
Query riders, find just who,
Joined the brigade fresh and new! 🚴

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main feature addition: a new rider sign-up date filter for the search functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description covers all required sections with detailed implementation details, a completed self-review checklist, and comprehensive summaries.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vn/filter-rider-signed-up

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@neal-bpm neal-bpm moved this to In Progress in Bike Brigade all things tech May 7, 2026
@neal-bpm neal-bpm marked this pull request as ready for review May 8, 2026 19:29
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/bike_brigade/riders/rider_search_test.exs (1)

245-263: ⚡ Quick win

Add exclusion-path tests for month and year.

You validate inclusion for month/year, but not explicit exclusion. Adding those two cases would close the regression gap around window boundaries.

Suggested additions
+    test "month - excludes rider who signed up more than a month ago" do
+      rider = fixture(:rider, %{signed_up_on: signed_up_ago(40, :day)})
+
+      {_rs, results} =
+        RiderSearch.new(filters: [%Filter{type: :signed_up, search: "month"}])
+        |> RiderSearch.fetch()
+
+      refute rider_in_results?(results, rider.id)
+    end
+
+    test "year - excludes rider who signed up more than a year ago" do
+      rider = fixture(:rider, %{signed_up_on: signed_up_ago(370, :day)})
+
+      {_rs, results} =
+        RiderSearch.new(filters: [%Filter{type: :signed_up, search: "year"}])
+        |> RiderSearch.fetch()
+
+      refute rider_in_results?(results, rider.id)
+    end

As per coding guidelines, “test/**/*.exs: Review test coverage and ExUnit best practices. Ensure tests are focused and descriptive.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/bike_brigade/riders/rider_search_test.exs` around lines 245 - 263, Add
two exclusion tests mirroring the existing inclusion specs: create tests named
like "month - excludes rider who signed up just over a month ago" and "year -
excludes rider who signed up just over a year ago"; each should create a rider
via fixture(:rider, %{signed_up_on: signed_up_ago(31, :day)}) and
fixture(:rider, %{signed_up_on: signed_up_ago(366, :day)}) respectively, run
RiderSearch.new(filters: [%Filter{type: :signed_up, search: "month"}]) |>
RiderSearch.fetch() and RiderSearch.new(... search: "year" ...) |>
RiderSearch.fetch(), and assert the rider is not returned using refute
rider_in_results?(results, rider.id) to close the boundary-regression gap.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/bike_brigade_web/live/rider_live/index.ex`:
- Line 51: The empty-search branch resets many fields on the suggestions map but
omits phone, leaving stale phone suggestions; update the map literal used there
(the %{suggestions | ...} expression in rider_live/index.ex) to also reset the
phone field (e.g., add phone: [] or phone: nil consistent with how
suggestions.phone is used elsewhere) so phone suggestions are cleared when the
search input is cleared.

In `@lib/bike_brigade/riders/rider_search.ex`:
- Around line 361-382: The apply_filter/3 function lacks a fallback clause for
%Filter{type: :signed_up}, causing a FunctionClauseError for unsupported search
values; add a catch-all clause for apply_filter(%Filter{type: :signed_up,
search: _}, query, _filters) that safely no-ops (returns the incoming query) or
rejects with a clear error, and place it after the existing :signed_up clauses
so unknown period values (e.g., "foo") don't crash the process; reference the
existing apply_filter/3 function and the Filter struct when implementing the
fallback.

---

Nitpick comments:
In `@test/bike_brigade/riders/rider_search_test.exs`:
- Around line 245-263: Add two exclusion tests mirroring the existing inclusion
specs: create tests named like "month - excludes rider who signed up just over a
month ago" and "year - excludes rider who signed up just over a year ago"; each
should create a rider via fixture(:rider, %{signed_up_on: signed_up_ago(31,
:day)}) and fixture(:rider, %{signed_up_on: signed_up_ago(366, :day)})
respectively, run RiderSearch.new(filters: [%Filter{type: :signed_up, search:
"month"}]) |> RiderSearch.fetch() and RiderSearch.new(... search: "year" ...) |>
RiderSearch.fetch(), and assert the rider is not returned using refute
rider_in_results?(results, rider.id) to close the boundary-regression gap.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6693a386-50ca-412d-88b7-dc98a9638a1a

📥 Commits

Reviewing files that changed from the base of the PR and between ff808be and 6b346ee.

📒 Files selected for processing (4)
  • lib/bike_brigade/riders/rider_search.ex
  • lib/bike_brigade_web/live/rider_live/index.ex
  • lib/bike_brigade_web/live/rider_live/index.html.heex
  • test/bike_brigade/riders/rider_search_test.exs

Comment thread lib/bike_brigade_web/live/rider_live/index.ex
Comment thread lib/bike_brigade/riders/rider_search.ex
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/bike_brigade_web/live/rider_live/index.ex">

<violation number="1" location="lib/bike_brigade_web/live/rider_live/index.ex:51">
P2: The `phone` field is missing from the suggestions reset when search is cleared, which can leave stale phone suggestions visible. Add `phone: nil` to the reset map.</violation>
</file>

<file name="lib/bike_brigade/riders/rider_search.ex">

<violation number="1" location="lib/bike_brigade/riders/rider_search.ex:361">
P2: Missing catch-all clause for `%Filter{type: :signed_up}` — any value outside the expected set (e.g. a crafted `signed_up:foo`) will raise a `FunctionClauseError`. Add a fallback that returns the query unchanged.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread lib/bike_brigade_web/live/rider_live/index.ex
Comment thread lib/bike_brigade/riders/rider_search.ex
@neal-bpm neal-bpm requested a review from mveytsman May 8, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant