Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds support for tracking service availability by day and scheduling closures for service centers.
- Introduces
ServiceAvailabilityandClosureSchedulemodels and correspondingDbSetentries. - Creates EF Core migrations and updates the model snapshot to include the new tables.
- Implements API endpoints in
ServiceControllerandClosureScheduleControllerfor querying and setting availability and closures.
Reviewed Changes
Copilot reviewed 31 out of 57 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Vpassbackend/Models/ServiceAvailability.cs | New model for per-day service availability |
| Vpassbackend/Models/ClosureSchedule.cs | New model for service center closure schedule |
| Vpassbackend/Data/ApplicationDbContext.cs | Added DbSet properties for the new models |
| Vpassbackend/Migrations/* | Multiple migrations to create/update the new tables |
| Vpassbackend/Controllers/ServiceController.cs | Endpoints for querying and updating availability |
| Vpassbackend/Controllers/ClosureScheduleController.cs | Endpoints for managing closure schedules |
| Vpassbackend/appsettings.json | Updated database connection string |
Files not reviewed (10)
- Vpassbackend/Migrations/20250709065437_InitialCreate.Designer.cs: Language not supported
- Vpassbackend/Migrations/20250710153706_AddServiceCenterManagement.Designer.cs: Language not supported
- Vpassbackend/Migrations/20250710160743_CreateServiceCenterServicesTable.Designer.cs: Language not supported
- Vpassbackend/Migrations/20250710161221_UpdateAppointmentModel.Designer.cs: Language not supported
- Vpassbackend/Migrations/20250710161540_UpdateAppointmentRelationships.Designer.cs: Language not supported
- Vpassbackend/Migrations/20250710190000_AddServiceReminders.Designer.cs: Language not supported
- Vpassbackend/Migrations/20250711060932_InitialCreate.Designer.cs: Language not supported
- Vpassbackend/Migrations/20250711072041_AddClosureScheduleAndServiceAvailability.Designer.cs: Language not supported
- Vpassbackend/Migrations/20250711090724_AddDayToServiceAvailability.Designer.cs: Language not supported
- Vpassbackend/Migrations/20250711124807_AddServiceAvailabilityAndClosureSchedule.Designer.cs: Language not supported
Comments suppressed due to low confidence (2)
Vpassbackend/Controllers/ClosureScheduleController.cs:17
- No unit or integration tests were added for this endpoint. Consider adding tests to verify duplicate detection and successful insertion.
public async Task<IActionResult> AddClosure([FromBody] ClosureSchedule closure)
Vpassbackend/Migrations/20250711072041_AddClosureScheduleAndServiceAvailability.cs:13
- Both this migration and
20250711124807_AddServiceAvailabilityAndClosureSchedule.cscreate the same tables. Consolidate or remove the duplicate migration to avoid conflicts.
migrationBuilder.CreateTable(
| protected override void Up(MigrationBuilder migrationBuilder) | ||
| { | ||
| migrationBuilder.CreateTable( | ||
| name: "ClosureSchedules", |
There was a problem hiding this comment.
Consider adding a foreign key constraint on ServiceCenterId to ServiceCenters and an index on (ServiceCenterId, WeekNumber, Day) for referential integrity and query performance.
| var services = _context.ServiceCenterServices | ||
| .Where(s => s.Station_id == serviceCenterId) | ||
| .Select(s => new { | ||
| s.ServiceId, | ||
| s.Service.ServiceName, | ||
| IsAvailable = !_context.ServiceAvailabilities.Any(a => | ||
| a.ServiceCenterId == serviceCenterId && | ||
| a.ServiceId == s.ServiceId && | ||
| a.WeekNumber == weekNumber && | ||
| !a.IsAvailable) |
There was a problem hiding this comment.
The LINQ .Any(...) subquery inside .Select may generate one correlated subquery per row. Consider loading availability data in a single query or using a join to reduce database round trips.
| var services = _context.ServiceCenterServices | |
| .Where(s => s.Station_id == serviceCenterId) | |
| .Select(s => new { | |
| s.ServiceId, | |
| s.Service.ServiceName, | |
| IsAvailable = !_context.ServiceAvailabilities.Any(a => | |
| a.ServiceCenterId == serviceCenterId && | |
| a.ServiceId == s.ServiceId && | |
| a.WeekNumber == weekNumber && | |
| !a.IsAvailable) | |
| var unavailableServices = _context.ServiceAvailabilities | |
| .Where(a => a.ServiceCenterId == serviceCenterId && | |
| a.WeekNumber == weekNumber && | |
| !a.IsAvailable) | |
| .ToList(); | |
| var unavailableServiceIds = new HashSet<int>(unavailableServices.Select(a => a.ServiceId)); | |
| var services = _context.ServiceCenterServices | |
| .Where(s => s.Station_id == serviceCenterId) | |
| .Select(s => new { | |
| s.ServiceId, | |
| s.Service.ServiceName, | |
| IsAvailable = !unavailableServiceIds.Contains(s.ServiceId) |
No description provided.