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 check cannot duty in different places at the same time #471

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

lleonard16
Copy link
Contributor

closes #296

@lleonard16 lleonard16 changed the title add check cannot duty in different laces at the same time add check cannot duty in different places at the same time Mar 29, 2020
Comment on lines 153 to 160
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
Copy link
Contributor

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.

Copy link
Contributor Author

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 😭

Copy link
Contributor Author

@lleonard16 lleonard16 Jun 23, 2020

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.

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.

Add check cannot duty in different place at the same time
3 participants