Skip to content

advanced filtering done and tested#107

Open
EmilJiang wants to merge 1 commit intomainfrom
advanced_filtering
Open

advanced filtering done and tested#107
EmilJiang wants to merge 1 commit intomainfrom
advanced_filtering

Conversation

@EmilJiang
Copy link
Contributor

@EmilJiang EmilJiang commented Mar 11, 2026

Advanced filtering for date

Summary by CodeRabbit

Release Notes

  • New Features
    • Added date-based filtering to narrow game schedules by timeframe (Today, Within 7 Days, Within a Month, Over a Month).
    • Filter selections are now preserved when reopening the advanced filters panel.
    • Added reset functionality to clear all applied filters at once.

@AndrewCheung360
Copy link
Member

@coderabbitai

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

@AndrewCheung360: Sure! I'll go ahead and review the PR now.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

This change adds date-based filtering functionality to the game schedule. The AdvancedFilterBottomSheet now accepts an initial date filter parameter, HomeScreen connects filter callbacks to the ViewModel, and HomeViewModel implements date filtering logic with state management for selected date filters.

Changes

Cohort / File(s) Summary
Filter UI Component
app/src/main/java/com/cornellappdev/score/components/AdvancedFiltersBottomSheet.kt
Added initialDate: DateFilter? = null parameter to accept and initialize pre-selected date filters from parent caller.
Screen Integration
app/src/main/java/com/cornellappdev/score/screen/HomeScreen.kt
Connected Advanced filter sheet to ViewModel by restoring the filter button visibility, passing initialDate = uiState.selectedDateFilter, and wiring onApply and onReset callbacks to ViewModel methods.
ViewModel & State Management
app/src/main/java/com/cornellappdev/score/viewmodel/HomeViewModel.kt
Extended HomeUiState with selectedDateFilter: DateFilter? = null property; implemented date filtering logic for TODAY, WITHIN_7_DAYS, WITHIN_A_MONTH, OVER_A_MONTH; added public methods onDateFilterApplied() and onFiltersReset().

Sequence Diagram

sequenceDiagram
    participant User
    participant HomeScreen
    participant AdvancedFilterBottomSheet
    participant HomeViewModel
    participant HomeUiState

    User->>HomeScreen: Tap Advanced Filter Button
    HomeScreen->>AdvancedFilterBottomSheet: Show with initialDate=selectedDateFilter
    User->>AdvancedFilterBottomSheet: Select Date Filter
    AdvancedFilterBottomSheet->>HomeScreen: onApply(dateFilter)
    HomeScreen->>HomeViewModel: onDateFilterApplied(dateFilter)
    HomeViewModel->>HomeUiState: Update selectedDateFilter
    HomeViewModel->>HomeViewModel: Re-filter games by date
    HomeViewModel->>HomeScreen: Emit updated loadedState
    HomeScreen->>User: Display filtered games
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A filter so fine, by date it may shine,
Games grouped near or far, by day or by calendar line,
From ViewModel's heart to the sheet's gentle start,
Date-based discovery—a fine filtering art! 📅

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description 'Advanced filtering for date' is extremely brief and lacks required sections; it's missing Overview, Changes Made, Test Coverage, and other template sections needed for proper documentation. Expand the description to follow the template: add Overview section explaining the feature, detailed Changes Made section, Test Coverage describing manual/unit testing with repro steps, and any applicable Next Steps or Related PRs.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'advanced filtering done and tested' is vague and generic, using non-descriptive phrasing that doesn't clearly convey the specific change (date filtering implementation). Revise the title to be more specific and descriptive, such as 'Implement date filtering for game schedules' or 'Add date-based filtering to advanced filters'.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch advanced_filtering
📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.

OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required.

Copy link

@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: 1

🧹 Nitpick comments (2)
app/src/main/java/com/cornellappdev/score/viewmodel/HomeViewModel.kt (1)

30-36: Inconsistent null handling across date filter cases.

Line 31 for TODAY relies on null == LocalDate.now() evaluating to false, while other cases explicitly check for null. This works but is inconsistent.

🧹 Suggested fix for consistency
                 val dateMatch = when (selectedDateFilter) {
-                    DateFilter.TODAY -> game.date == LocalDate.now()
+                    DateFilter.TODAY -> game.date != null && game.date == LocalDate.now()
                     DateFilter.WITHIN_7_DAYS -> game.date != null && !game.date.isAfter(LocalDate.now().plusDays(7))
                     DateFilter.WITHIN_A_MONTH -> game.date != null && !game.date.isAfter(LocalDate.now().plusDays(30))
                     DateFilter.OVER_A_MONTH -> game.date != null && game.date.isAfter(LocalDate.now().plusDays(30))
                     null -> true
                 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/cornellappdev/score/viewmodel/HomeViewModel.kt` around
lines 30 - 36, The date filter when-block in HomeViewModel (the val dateMatch
assignment) treats DateFilter.TODAY differently by not checking game.date for
null; change the TODAY branch to explicitly guard against null like the other
branches (e.g., DateFilter.TODAY -> game.date != null && game.date ==
LocalDate.now()) so every case consistently checks game.date before accessing
it.
app/src/main/java/com/cornellappdev/score/components/AdvancedFiltersBottomSheet.kt (1)

23-23: Minor: Duplicate @OptIn annotation.

The ExperimentalMaterial3Api::class is listed twice in the same annotation.

🧹 Suggested fix
-@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3Api::class)
+@OptIn(ExperimentalMaterial3Api::class)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/cornellappdev/score/components/AdvancedFiltersBottomSheet.kt`
at line 23, The `@OptIn` annotation in AdvancedFiltersBottomSheet is duplicated
(ExperimentalMaterial3Api::class appears twice); remove the redundant entry so
the annotation only lists ExperimentalMaterial3Api::class once (i.e., keep a
single `@OptIn`(ExperimentalMaterial3Api::class)) to clean up the duplicate
import/annotation above the AdvancedFiltersBottomSheet declaration.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/main/java/com/cornellappdev/score/screen/HomeScreen.kt`:
- Around line 95-101: The AdvancedFilterBottomSheet onApply lambda currently
receives price, location, date but only forwards date via
homeViewModel.onDateFilterApplied, silently ignoring price/location; either
disable the price/location UI in AdvancedFilterBottomSheet until implemented, or
add a TODO and a proper forwarding stub: update the onApply handler in
HomeScreen (where onApply = { price, location, date -> ... }) to either (A) call
a new ViewModel method homeViewModel.onFiltersApplied(price, location, date)
(create a stub onFiltersApplied in HomeViewModel to accept price and location
and wire it later), or (B) add a clear TODO comment in the onApply block and
disable the price/location sections in AdvancedFilterBottomSheet so selections
are not available to users; also ensure onReset still calls
homeViewModel.onFiltersReset and initialDate uses uiState.selectedDateFilter.

---

Nitpick comments:
In
`@app/src/main/java/com/cornellappdev/score/components/AdvancedFiltersBottomSheet.kt`:
- Line 23: The `@OptIn` annotation in AdvancedFiltersBottomSheet is duplicated
(ExperimentalMaterial3Api::class appears twice); remove the redundant entry so
the annotation only lists ExperimentalMaterial3Api::class once (i.e., keep a
single `@OptIn`(ExperimentalMaterial3Api::class)) to clean up the duplicate
import/annotation above the AdvancedFiltersBottomSheet declaration.

In `@app/src/main/java/com/cornellappdev/score/viewmodel/HomeViewModel.kt`:
- Around line 30-36: The date filter when-block in HomeViewModel (the val
dateMatch assignment) treats DateFilter.TODAY differently by not checking
game.date for null; change the TODAY branch to explicitly guard against null
like the other branches (e.g., DateFilter.TODAY -> game.date != null &&
game.date == LocalDate.now()) so every case consistently checks game.date before
accessing it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66ea7440-b6c6-4f3c-a150-3c77459e7ced

📥 Commits

Reviewing files that changed from the base of the PR and between 254d1c7 and f342092.

📒 Files selected for processing (3)
  • app/src/main/java/com/cornellappdev/score/components/AdvancedFiltersBottomSheet.kt
  • app/src/main/java/com/cornellappdev/score/screen/HomeScreen.kt
  • app/src/main/java/com/cornellappdev/score/viewmodel/HomeViewModel.kt

Comment on lines 95 to +101
onApply = { price, location, date ->
// TODO: forward to ViewModel
homeViewModel.onDateFilterApplied(date)
},
onReset = {
// TODO: reset filters in ViewModel
}
homeViewModel.onFiltersReset()
},
initialDate = uiState.selectedDateFilter
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Price and location filter parameters are silently ignored.

The onApply callback receives price, location, and date, but only date is forwarded to the ViewModel. If the UI allows selecting price/location filters, users may be confused when those selections have no effect.

Consider either:

  1. Disabling price/location sections in AdvancedFilterBottomSheet until implemented, or
  2. Adding a TODO comment to track the remaining filter implementations.

Would you like me to open an issue to track implementing the price and location filters?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/cornellappdev/score/screen/HomeScreen.kt` around lines
95 - 101, The AdvancedFilterBottomSheet onApply lambda currently receives price,
location, date but only forwards date via homeViewModel.onDateFilterApplied,
silently ignoring price/location; either disable the price/location UI in
AdvancedFilterBottomSheet until implemented, or add a TODO and a proper
forwarding stub: update the onApply handler in HomeScreen (where onApply = {
price, location, date -> ... }) to either (A) call a new ViewModel method
homeViewModel.onFiltersApplied(price, location, date) (create a stub
onFiltersApplied in HomeViewModel to accept price and location and wire it
later), or (B) add a clear TODO comment in the onApply block and disable the
price/location sections in AdvancedFilterBottomSheet so selections are not
available to users; also ensure onReset still calls homeViewModel.onFiltersReset
and initialDate uses uiState.selectedDateFilter.

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.

2 participants