-
Notifications
You must be signed in to change notification settings - Fork 0
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 check cannot duty in different places at the same time #471
base: master
Are you sure you want to change the base?
add check cannot duty in different places at the same time #471
Conversation
…ty-in-different-places-at-the-same-time
…ime' of https://github.com/nussucommit/takoyaki into add-check-cannot-duty-in-different-places-at-the-same-time
app/controllers/duties_controller.rb
Outdated
timeslot = duty.timeslot | ||
user_on_duty = Duty.joins(:timeslot) | ||
.where(timeslots: { time_range_id: | ||
timeslot.time_range_id }) | ||
.where.not(timeslots: { place_id: | ||
timeslot.place_id }) | ||
.exists?(user_id: current_user.id) | ||
raise StandardError, 'You need to duty in other places!' if user_on_duty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the code to grabable?
method instead? I feel like it is more suited there. grab_duty
is for duties that can definitely be grabbed, it is just a driver to executing the database update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear Ryo, I have tried my best to rewrite and rearrange the method. After spending several hours on it, It can now pass ruboco check on my local machine haha. However, though it seems that the overall coverage has not dropped, I am very sorry that there are still some build problems that I was not able to solve after spending 3 hours on it 😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Ryo, I have finally solved the problem. I have debugged and now it passed all tests. It will check if the user is dutying at two different places at the same time after running the generate duty or grab duty. It will now pop up warnings if a user is dutying at different places at the same time.
closes #296