refactor(schedule): prepare to include tutorials
This commit is contained in:
parent
6ac1dc57d0
commit
2d38172363
@ -43,7 +43,7 @@ weekSchedule uid _weekOffset = do
|
||||
return $ term E.^. TermId
|
||||
|
||||
-- TODO: fetch course events for this week only?
|
||||
courseEvents'' <- liftHandler . runDB $ E.select $ E.from $ \(course `E.InnerJoin` courseEvent) -> do
|
||||
courseEvents <- liftHandler . runDB $ E.select $ E.from $ \(course `E.InnerJoin` courseEvent) -> do
|
||||
E.on $ course E.^. CourseId E.==. courseEvent E.^. CourseEventCourse
|
||||
--E.where_ $ E.exists $ E.from $ \term -> E.where_ $
|
||||
-- term E.^. TermId E.==. course E.^. CourseTerm
|
||||
@ -59,7 +59,6 @@ weekSchedule uid _weekOffset = do
|
||||
)
|
||||
return (course, courseEvent)
|
||||
|
||||
-- TODO: include in schedule
|
||||
_tutorials <- liftHandler . runDB $ E.select $ E.from $ \(course `E.InnerJoin` tutorial) -> do
|
||||
E.on $ course E.^. CourseId E.==. tutorial E.^. TutorialCourse
|
||||
--E.where_ $ E.exists $ E.from $ \term -> E.where_ $
|
||||
@ -99,17 +98,19 @@ weekSchedule uid _weekOffset = do
|
||||
Left ExceptNoOccur{exceptTime=LocalTime{..}} -> (localDay, localTimeOfDay, Nothing)
|
||||
in day == day' && TimeOfDay slot 0 0 <= start && start < TimeOfDay (slot+slotStep) 0 0
|
||||
|
||||
courseEvents' :: Map Day (Map TimeSlot [ScheduleEntry])
|
||||
courseEvents' = Map.fromList $ currentWeek <&> \day ->
|
||||
events' :: Map Day (Map TimeSlot [ScheduleEntry])
|
||||
events' = Map.fromList $ currentWeek <&> \day ->
|
||||
( day
|
||||
, Map.fromList $ slotsToDisplay <&> \slot ->
|
||||
( slot
|
||||
, filter (seOccurrenceIsInSlot day slot . seOccurrence) $ join $ courseEventToScheduleEntries <$> courseEvents''
|
||||
, filter (seOccurrenceIsInSlot day slot . seOccurrence) $ join $ courseEventToScheduleEntries <$> courseEvents
|
||||
-- TODO: include tutorials
|
||||
-- TODO: incluse exams (maybe)
|
||||
)
|
||||
)
|
||||
|
||||
courseEvents :: Map Day (Map TimeSlot [ScheduleEntry])
|
||||
courseEvents = courseEvents' <&> \slotsPerDay -> slotsPerDay <&> \occurrencesInSlot ->
|
||||
events :: Map Day (Map TimeSlot [ScheduleEntry])
|
||||
events = events' <&> \slotsPerDay -> slotsPerDay <&> \occurrencesInSlot ->
|
||||
let
|
||||
isRegularWithoutException :: ScheduleEntry -> Bool
|
||||
isRegularWithoutException = \case
|
||||
|
||||
@ -16,7 +16,7 @@ $newline never
|
||||
$forall (day, _, _) <- weekDays
|
||||
<td .table__td>
|
||||
<div .table__td-content>
|
||||
$maybe dayEvents <- Map.lookup day courseEvents
|
||||
$maybe dayEvents <- Map.lookup day events
|
||||
$maybe slotEvents <- Map.lookup slot dayEvents
|
||||
$forall ScheduleEntry{seCourse=Entity _ Course{courseTerm,courseSchool,courseShorthand,courseName},seType,seRoom,seOccurrence} <- slotEvents
|
||||
<a href=@{CourseR courseTerm courseSchool courseShorthand CShowR} .schedule--entry-link>
|
||||
|
||||
Reference in New Issue
Block a user