Calendar events (backend) - #381
Conversation
WalkthroughAdds calendar events backed by dated timeslots and participant availability records. Backend serializers, validation, creation/editing endpoints, event details, bounds, dashboard queries, and availability APIs now recognize the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 109c07dd-667a-42f0-baad-ff1b6962c654
📒 Files selected for processing (12)
backend/api/availability/utils.pybackend/api/availability/views.pybackend/api/dashboard/views.pybackend/api/event/serializers.pybackend/api/event/urls.pybackend/api/event/utils.pybackend/api/event/views.pybackend/api/migrations/0034_alter_userevent_date_type_eventcalendartimeslot_and_more.pybackend/api/models.pybackend/api/utils.pyfrontend/src/lib/utils/api/endpoints.tsfrontend/src/lib/utils/api/types.ts
This PR adds the backend implementation for date-only events, referred to as a "calendar" event on the backend.
New Database Tables
Two new tables were added to the database,
EventCalendarTimeslotandEventCalendarAvailability. These are structurally about the same as their respective tables for the other event types. The only difference is that the timeslots store just dates, not datetimes.New Endpoints
/event/calendar-create//event/calendar-edit/These endpoints take the same data as their respective endpoints for the other event types.
It's worth noting that this identical data format means that the backend accepts datetimes for timeslots for calendar events, instead of only dates. This should make it much easier to implement on the frontend with the existing logic, instead of having to adapt the logic to convert to dates.
Updated Endpoints
/event/get-details//availability/add//availability/get-self//availability/get-all//dashboard/get/The logic in these endpoints was extended to support calendar type events. It was mostly reused logic, just leveraging different fields on the database tables.
Fixed Error Logging Issue
Apparently I never noticed that I was trying to access
UserEvent.idwhen logging an error for missing timeslots. The correct field isUserEvent.user_event_id, and that has been fixed in the relevant locations.New Util Function
to_datetimewas created to convertdateobjects intodatetimeobjects at midnight, making it much easier to convert data between the database format and format used by the existing API logic.A Note on Testing
If you migrate your database to this new version when testing, you will need to delete any calendar events you create before unapplying the migrations to go back to other versions. You can do this from the dashboard on the frontend, as the events display there, albeit not with the correct data. Otherwise, you can just call the event deletion endpoint,