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

Add gather command by tags #109

Conversation

AlyssaPng
Copy link
Collaborator

@AlyssaPng AlyssaPng commented Oct 22, 2023

Add gather command by tags for enhancement

@AlyssaPng AlyssaPng added this to the v1.3 milestone Oct 22, 2023
@codecov
Copy link

codecov bot commented Oct 22, 2023

Codecov Report

Merging #109 (1886550) into master (c97175d) will increase coverage by 0.23%.
Report is 4 commits behind head on master.
The diff coverage is 96.61%.

@@             Coverage Diff              @@
##             master     #109      +/-   ##
============================================
+ Coverage     76.29%   76.53%   +0.23%     
- Complexity      544      571      +27     
============================================
  Files            88       91       +3     
  Lines          1772     1828      +56     
  Branches        178      186       +8     
============================================
+ Hits           1352     1399      +47     
- Misses          372      375       +3     
- Partials         48       54       +6     
Files Coverage Δ
...va/seedu/address/logic/commands/GatherCommand.java 100.00% <100.00%> (ø)
src/main/java/seedu/address/model/AddressBook.java 83.87% <ø> (ø)
src/main/java/seedu/address/model/Model.java 100.00% <ø> (ø)
...rc/main/java/seedu/address/model/ModelManager.java 100.00% <ø> (ø)
...edu/address/model/financialplan/FinancialPlan.java 73.33% <100.00%> (+1.90%) ⬆️
...c/main/java/seedu/address/model/person/Person.java 96.92% <100.00%> (+0.43%) ⬆️
...a/seedu/address/model/person/UniquePersonList.java 88.67% <100.00%> (ø)
...person/gatheremail/GatherEmailByFinancialPlan.java 100.00% <100.00%> (ø)
...ess/model/person/gatheremail/GatherEmailByTag.java 100.00% <100.00%> (ø)
src/main/java/seedu/address/model/tag/Tag.java 73.33% <100.00%> (+1.90%) ⬆️
... and 1 more

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@AlyssaPng AlyssaPng changed the title Add Gather Command By Tags Add Gather Command by Tags Oct 22, 2023
@AlyssaPng AlyssaPng changed the title Add Gather Command by Tags Add gather command by tags Oct 22, 2023
Copy link
Collaborator

@sopa301 sopa301 left a comment

Choose a reason for hiding this comment

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

I think it's quite a good idea to use a Command Pattern to implement the gather command. Nice work!

As a side note, perhaps it would be more readable to rename GatherEmails to a noun instead of a verb like GatherEmailPrompt or something since it would make it easier to reason about, as well as being more intuitive for first-timers.

Also, putting these into a separate folder would make the file structure more neat.

Copy link
Collaborator

@Kb-Tay Kb-Tay left a comment

Choose a reason for hiding this comment

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

Implementation wise LGTM. However, can consider the following suggestions made. Can also include more testing for invalid command inputs.

Comment on lines 16 to 17
public static final String FINANCIAL_PLAN_REGEX = "^[a-zA-Z0-9\\s]+";
public static final String TAG_REGEX = "\\p{Alnum}+";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe can abstract validation regex to the respective field classes

Comment on lines 19 to 20
public static final String FINANCIAL_PLAN_CONSTRAINTS = "PROMPT should be alphanumeric or space characters";
public static final String TAG_CONSTRAINTS = "Tags names should be alphanumeric";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe can abstract messages to respective field classes too

Comment on lines 31 to 45
if (trimmedArgs.contains(PREFIX_FINANCIAL_PLAN.getPrefix())) {
// Parse Financial Plan
argDescription = trimmedArgs.replace(PREFIX_FINANCIAL_PLAN.getPrefix(), "").trim();
validateInput(argDescription, FINANCIAL_PLAN_REGEX, FINANCIAL_PLAN_CONSTRAINTS);
return new GatherCommand(new GatherEmailsByFinancialPlan(argDescription));
} else if (trimmedArgs.contains(PREFIX_TAG.getPrefix())) {
// Parse Tag
argDescription = trimmedArgs.replace(PREFIX_TAG.getPrefix(), "").trim();
validateInput(argDescription, TAG_REGEX, TAG_CONSTRAINTS);
return new GatherCommand(new GatherEmailsByTag(argDescription));
}

if (!trimmedArgs.matches(VALIDATION_REGEX)) {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, GatherCommand.MESSAGE_USAGE));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could consider using ArgumentMultiMap class instead, can try refering to the EditCommandParser. This implementation might introduce bugs, for example, what happens if the prefix given by the person is ot/ and the contains method checks that PREFIX_TAG is present?

Copy link

@nikele2001 nikele2001 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Collaborator

@sopa301 sopa301 left a comment

Choose a reason for hiding this comment

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

LGTM

@sopa301 sopa301 merged commit c3fe2e7 into AY2324S1-CS2103T-F12-1:master Oct 23, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants