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

Remove invalid assignments after worker/shift edit #113

Merged
merged 11 commits into from
Oct 28, 2020

Conversation

tnsyn
Copy link

@tnsyn tnsyn commented Oct 28, 2020

Resolves #109

@codecov-io
Copy link

Codecov Report

Merging #113 into master will decrease coverage by 0.34%.
The diff coverage is 15.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #113      +/-   ##
============================================
- Coverage     66.53%   66.18%   -0.35%     
  Complexity      715      715              
============================================
  Files           127      127              
  Lines          2552     2570      +18     
  Branches        329      333       +4     
============================================
+ Hits           1698     1701       +3     
- Misses          743      756      +13     
- Partials        111      113       +2     
Impacted Files Coverage Δ Complexity Δ
...eedu/address/logic/commands/WorkerEditCommand.java 80.58% <11.11%> (-5.74%) 15.00 <0.00> (ø)
...seedu/address/logic/commands/ShiftEditCommand.java 68.96% <18.18%> (-6.36%) 15.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29d7be2...ea1fc85. Read the comment docs.

Copy link

@wakululuu wakululuu left a comment

Choose a reason for hiding this comment

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

WorkerEditCommand looks good but I think there is a somewhat major problem with ShiftEditCommand.

Comment on lines 136 to 138
Role assignedRole = assignment.getRole();
Set<Role> editedWorkerRoles = editedWorker.getRoles();
if (!editedWorkerRoles.contains(assignedRole)) {

Choose a reason for hiding this comment

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

Suggested change
Role assignedRole = assignment.getRole();
Set<Role> editedWorkerRoles = editedWorker.getRoles();
if (!editedWorkerRoles.contains(assignedRole)) {
if (!editedWorker.isFitForRole(assignment.getRole())) {

Copy link
Author

Choose a reason for hiding this comment

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

Looks better, will change!

Comment on lines 117 to 118
Set<RoleRequirement> newRoleRequirements = editedShift.getRoleRequirements();
newRoleRequirements.forEach(roleRequirement -> newRoles.add(roleRequirement.getRole()));

Choose a reason for hiding this comment

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

Perhaps these two lines can be moved out of and before the for loop.

Copy link
Author

Choose a reason for hiding this comment

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

I've made this into a method called getRoles() inside the Shift class!

Comment on lines 119 to 120
if (!newRoles.contains(assignmentRole)) {
assignmentsToDelete.add(assignment);

Choose a reason for hiding this comment

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

Seems like this only works for the case where a role requirement that was present in a shift is completely removed from it. I don't think the case where the quantityRequired of a role is changed but the role remains unchanged has been accounted for.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, thanks for reminding me! Will add the checks for this

@tnsyn tnsyn requested a review from wakululuu October 28, 2020 16:53
Copy link

@wakululuu wakululuu left a comment

Choose a reason for hiding this comment

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

LGTM other than the merge conflict to be resolved

@tnsyn tnsyn merged commit cc32008 into AY2021S1-CS2103-F10-4:master Oct 28, 2020
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.

Remove assignments that are no longer valid after commands
3 participants