@@ -892,6 +892,15 @@ export const timeSlotRouter = router({
892892 } ;
893893 }
894894
895+ // MLH slot duration in minutes - must divide evenly into slotDurationMinutes
896+ const MLH_SLOT_MINUTES = 2.5 ;
897+ if ( input . slotDurationMinutes % MLH_SLOT_MINUTES !== 0 ) {
898+ throw new TRPCError ( {
899+ code : "BAD_REQUEST" ,
900+ message : `slotDurationMinutes (${ input . slotDurationMinutes } ) must be divisible by MLH slot duration (${ MLH_SLOT_MINUTES } )` ,
901+ } ) ;
902+ }
903+
895904 // Separate MLH and non-MLH tracks
896905 const mlhProjectTracks = allProjectTracks . filter (
897906 ( pt ) => pt . track . name === "MLH" ,
@@ -973,7 +982,9 @@ export const timeSlotRouter = router({
973982 ) ;
974983
975984 // Schedule MLH judging slots
976- const mlhSlotsToSchedule = Math . floor ( input . slotDurationMinutes / 5 ) ;
985+ const mlhSlotsToSchedule = Math . floor (
986+ input . slotDurationMinutes / MLH_SLOT_MINUTES ,
987+ ) ;
977988 let mlhStartTime = currentTimeChunk ;
978989
979990 for (
@@ -1002,9 +1013,7 @@ export const timeSlotRouter = router({
10021013 projectId : chosenProject . projectId ,
10031014 startTime : mlhStartTime ,
10041015 endTime : new Date (
1005- new Date ( mlhStartTime ) . setMinutes (
1006- mlhStartTime . getMinutes ( ) + 5 ,
1007- ) ,
1016+ mlhStartTime . getTime ( ) + MLH_SLOT_MINUTES * 60 * 1000 ,
10081017 ) ,
10091018 dhYear : dhYearConfig . value ,
10101019 } ,
@@ -1036,7 +1045,7 @@ export const timeSlotRouter = router({
10361045 } ) ;
10371046
10381047 mlhStartTime = new Date (
1039- new Date ( mlhStartTime ) . setMinutes ( mlhStartTime . getMinutes ( ) + 5 ) ,
1048+ mlhStartTime . getTime ( ) + MLH_SLOT_MINUTES * 60 * 1000 ,
10401049 ) ;
10411050 }
10421051 currentTimeChunk = new Date (
@@ -1053,18 +1062,14 @@ export const timeSlotRouter = router({
10531062 projectId : mlhProject . projectId ,
10541063 startTime : currentTimeChunk ,
10551064 endTime : new Date (
1056- new Date ( currentTimeChunk ) . setMinutes (
1057- currentTimeChunk . getMinutes ( ) + 5 , // 5 minute slots for MLH
1058- ) ,
1065+ currentTimeChunk . getTime ( ) + MLH_SLOT_MINUTES * 60 * 1000 ,
10591066 ) ,
10601067 dhYear : dhYearConfig . value ,
10611068 } ,
10621069 } ) ;
10631070
10641071 currentTimeChunk = new Date (
1065- new Date ( currentTimeChunk ) . setMinutes (
1066- currentTimeChunk . getMinutes ( ) + 5 ,
1067- ) ,
1072+ currentTimeChunk . getTime ( ) + MLH_SLOT_MINUTES * 60 * 1000 ,
10681073 ) ;
10691074 }
10701075
0 commit comments