Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent search #129

Merged

Conversation

jan-kai1
Copy link
Collaborator

@jan-kai1 jan-kai1 commented Oct 29, 2024

Trial Implementation of a persistent search function to group multiple selections

Issues

UI

  • Have NOT implemented UI for the full list of Persons
    Currently no way to see who you are trying to add

Testing

  • Unsure how to check equality for SearchModeSearchCommands due to difficulty in checking Predicate Equality

Commands generated by SearchModeSearchCommandParser are based on Strings, making it difficult to check equality of different SearchModeSearchCommands generated.
No idea how to check equality of different Predicates

  • Testing of equality of functions used for FieldContainsKeywordPredicate
    FieldContainsKeyWordPredicate currently uses a lambda function to parse out the target field from a person object. May be difficult to test equality

Alternative: Separate each field Predicate into its own separate method.

ErrorHandling

  • empty input field matches everything (should be easy fix)

searchmode implementation

searchmode is tracked by a boolean value searchMode in the ModelManager class. When searchMode is true, the commands accepted by the app changes.

  • ModelManager also tracks the last used Predicate used to filter its list lastPredicate

The displayed list will be modified by chaining lastPredicate with Predicates generated based on user parameter input using FieldContainsKeywordPredicate class

Enter search mode using searchmode

Searchmode commands

exitsearchmode

Exits searchmode, returning to view of all contacts

search n/{String} e/{String p/ ...

Searches for contacts that matches ALL search parameter criteria

The search parsing currently implemented to check if a person field contains or contains a word equal to the string
This is done in the using the FieldContainsKeywordsPredicate class

This is currently implemented using a SearchModeSearchCommand class that tracks a Set<Predicate>
Upon .execute, the Set<Predicate> is reduced using the .and method to create a final predicate used to filter the list

The predicates are currently stored in a set rather than immediately chaining them using .and due to equality checking

Chaining Searches

Searches with multiple criteria can be chained using separate search commands
search n/Alex
would first add to the displayed list all Persons with name containing Alex

search n/Roy
Adds again to the current displayed list all Persons with name containing Roy

This is done using .or method to combine the new SearchModeSearchCommand predicate with lastPredicate in model manager

@jan-kai1 jan-kai1 self-assigned this Oct 29, 2024
@jan-kai1 jan-kai1 added type.Enhancement An enhancement to an existing story priority.Medium Nice to have labels Oct 29, 2024
@jan-kai1 jan-kai1 added this to the v1.5 milestone Oct 29, 2024
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 24.34783% with 87 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ss/logic/parser/SearchModeSearchCommandParser.java 0.00% 46 Missing ⚠️
.../seedu/address/logic/parser/AddressBookParser.java 0.00% 13 Missing ⚠️
...s/model/person/FieldContainsKeywordsPredicate.java 57.89% 3 Missing and 5 partials ⚠️
...gic/commands/searchmode/ExitSearchModeCommand.java 0.00% 6 Missing ⚠️
...gic/commands/searchmode/InitSearchModeCommand.java 0.00% 6 Missing ⚠️
...c/commands/searchmode/SearchModeSearchCommand.java 71.42% 3 Missing and 1 partial ⚠️
...rc/main/java/seedu/address/logic/LogicManager.java 25.00% 2 Missing and 1 partial ⚠️
...rc/main/java/seedu/address/model/ModelManager.java 85.71% 1 Missing ⚠️
Files with missing lines Coverage Δ Complexity Δ
src/main/java/seedu/address/model/Model.java 100.00% <ø> (ø) 1.00 <0.00> (ø)
...rc/main/java/seedu/address/model/ModelManager.java 96.82% <85.71%> (-3.18%) 30.00 <3.00> (+2.00) ⬇️
...rc/main/java/seedu/address/logic/LogicManager.java 67.85% <25.00%> (-8.15%) 3.00 <0.00> (ø)
...c/commands/searchmode/SearchModeSearchCommand.java 71.42% <71.42%> (ø) 4.00 <4.00> (?)
...gic/commands/searchmode/ExitSearchModeCommand.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...gic/commands/searchmode/InitSearchModeCommand.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...s/model/person/FieldContainsKeywordsPredicate.java 57.89% <57.89%> (ø) 6.00 <6.00> (?)
.../seedu/address/logic/parser/AddressBookParser.java 61.11% <0.00%> (-38.89%) 15.00 <0.00> (ø)
...ss/logic/parser/SearchModeSearchCommandParser.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)

@jan-kai1 jan-kai1 marked this pull request as ready for review October 29, 2024 10:59
@jan-kai1 jan-kai1 merged commit a9846ef into AY2425S1-CS2103T-F09-2:PersistentSearch Oct 29, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority.Medium Nice to have type.Enhancement An enhancement to an existing story
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant