Repository navigation
Add event check-in configuration API - #208
choidanny719 wants to merge 4 commits into
Conversation
| index=True, | ||
| ) | ||
|
|
||
| name: Mapped[str] = mapped_column(String(64)) |
There was a problem hiding this comment.
Use the constant defined for the model for the length of the name.
| class EventCheckInCreate(BaseModel): | ||
| model_config = ConfigDict(extra="forbid") | ||
|
|
||
| name: str = Field(min_length=1, max_length=64, pattern=r"\S") |
There was a problem hiding this comment.
Define a constant for the max_length.
| class EventCheckInUpdate(BaseModel): | ||
| model_config = ConfigDict(extra="forbid") | ||
|
|
||
| name: str | None = Field(default=None, min_length=1, max_length=64, pattern=r"\S") |
There was a problem hiding this comment.
Use the constant defined for the model for the length of the name.
There was a problem hiding this comment.
Have the fields in the models be Field(...) and add descriptions so our documentation is better. See src/users/models.py for examples.
| sa.Column("id", sa.BigInteger(), sa.Identity(always=True), nullable=False), | ||
| sa.Column("event_id", sa.Integer(), nullable=False), | ||
| sa.Column("name", sa.String(length=64), nullable=False), | ||
| sa.Column("enabled", sa.Boolean(), server_default=sa.text("false"), nullable=False), |
There was a problem hiding this comment.
| sa.Column("enabled", sa.Boolean(), server_default=sa.text("false"), nullable=False), | |
| sa.Column("enabled", sa.Boolean(), server_default=sa.false(), nullable=False), |
This is to prevent our SQL statement scanner from flagging this as unsafe.
| from event_check_in.tables import EventCheckInDB | ||
| from utils.shared_models import DetailModel | ||
|
|
||
| CheckInIdPath = Annotated[int, Path(ge=1, le=9223372036854775807)] |
There was a problem hiding this comment.
Make a constant for the le number, put it in src/constants.py.
There was a problem hiding this comment.
Add explicit operation IDs to endpoints as we use those to generate functions in other applications. For example, GET /api/event/{eid}/check-in has an implicit operation ID of list_check_ins_api_event__eid__check_in_get, which is a bit too long. Operation ID could be get_check_ins
| event_id = await _get_event_id(db_session, eid) | ||
| check_in = await event_check_in.crud.get_check_in(db_session, event_id, check_in_id) |
There was a problem hiding this comment.
We can reduce the number of trips to the database by using a join. This would involve modifying crud.get_check_in to take in eid instead of event_id and joining with EventDB. We can keep the error ambiguous by just saying "Event or event check-in configuration is missing".
| event_id = await _get_event_id(db_session, eid) | ||
| check_in = await event_check_in.crud.get_check_in(db_session, event_id, check_in_id, for_update=True) |
There was a problem hiding this comment.
We can reduce the number of trips to the database by using a join. This would involve modifying crud.get_check_in to take in eid instead of event_id and joining with EventDB. We can keep the error ambiguous by just saying "Event or event check-in configuration is missing".
There was a problem hiding this comment.
Add a few more tests:
- Check that multiple check-ins for a single event operates normally. Create multiple check-ins, update and/or delete them and ensure the other is not affected.
- Check that deletion cascades. Create an event, add one or more check-in configurations, and delete the event. The result should be all check-in configurations are gone.
- POST with invalid time ranges should return 422.
- PATCH with a name of "null" should return 422.
- Ensure
created_atis preserved andupdated_atis modified when an entry is updated.
Implements #201 by allowing CSSS events to have multiple configurable check-in periods.
execpermissions for reads andeventpermissions for changes.Configuration IDs are included in responses, and creation/update timestamps are managed by the server.
Validated locally with 13 unit tests and 37 integration tests covering CRUD operations, validation, permissions, missing events, and access through incorrect event IDs. Ruff lint and formatting checks passed.