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 for conflicting events before creation #129

Merged
merged 2 commits into from
Apr 12, 2022

Conversation

vetlek
Copy link
Contributor

@vetlek vetlek commented Apr 11, 2022

Closes #95

@vetlek vetlek force-pushed the add_verification_pose_event branch 2 times, most recently from 7200116 to 079bddd Compare April 11, 2022 09:29
backend/src/flotilla/database/models.py Outdated Show resolved Hide resolved
backend/src/flotilla/database/models.py Outdated Show resolved Hide resolved
backend/tests/test_crud.py Outdated Show resolved Hide resolved
backend/src/flotilla/database/crud.py Outdated Show resolved Hide resolved
@tsundvoll
Copy link
Contributor

I think this looks good. When my comments above are solved I will approve.

@vetlek vetlek force-pushed the add_verification_pose_event branch from 079bddd to 6100203 Compare April 12, 2022 06:42
if overlapping_events:
raise HTTPException(
status_code=HTTPStatus.CONFLICT.value,
detail=f"Conflict with already existing event in the same time period. Events with id: {','.join(str(event.id) for event in overlapping_events)}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Will all users be authorized to see all events for a given robot?
If not, this might be giving out too much information, maybe the first statement is enough?
I'm not sure, open for discussion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would say that if the user is authorized to post events (which I believe should have a "higher" access level than just read events) they will be allowed to see all events.

@@ -62,11 +63,24 @@ async def post_event(
) -> Event:
"""Add a new event to the robot schedule"""
try:
end_time = event_request.start_time + DEFAULT_EVENT_DURATION
Copy link
Contributor

@GodVenn GodVenn Apr 12, 2022

Choose a reason for hiding this comment

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

Will we always use the default duration? Maybe the user should have an event_duration optional field to this post endpoint so they can define it themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently a default value is enough in my opinion. I don't think the user should be able to set the event_duration, but rather be based on the number of tags and/or based on data from previous missions with the same id. Can make a card for setting the event_duration based on number of tags.

@vetlek vetlek force-pushed the add_verification_pose_event branch from 6100203 to c8d0925 Compare April 12, 2022 08:31
Copy link
Contributor

@tsundvoll tsundvoll left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@vetlek vetlek merged commit 20a07e9 into equinor:main Apr 12, 2022
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 for time conflicts for the post event endpoint
3 participants