Add getAllLecturesCached

This commit is contained in:
2022-09-05 16:31:06 +02:00
parent ace0bee9d6
commit bb9a0643f1
5 changed files with 131 additions and 9 deletions
+13 -1
View File
@@ -130,6 +130,8 @@ data Document = Document
, documentFaculty :: Faculty
, documentLectures :: [Lecture]
, documentDownloadable :: Bool
, documentType :: Text
, documentNumPages :: Int
}
deriving (Show, Generic)
@@ -171,7 +173,17 @@ getAllDocuments :: (SqueakCtx m, MonadIO m) => m (Either SqueakError [Document])
getAllDocuments = fmap unDocuments <$> joinErrors <$> mkQuery
"{ documents(filters: []) \
\ { results \
\ { id date semester publicComment downloadable faculty { id displayName } lectures { id displayName aliases } } \
\ { id date semester publicComment downloadable faculty { id displayName } lectures { id displayName aliases } type numPages } \
\ } \
\}"
getDocumentsByLectureId :: (SqueakCtx m, MonadIO m) => Text -> m (Either SqueakError [Document])
getDocumentsByLectureId lecture = fmap unDocuments <$> joinErrors <$> mkQueryWithVars
(object ["lecture" .= lecture])
"query DocumentsByLectureId($lecture: LectureId!) \
\ { documents(filters: [{ lectures: [$lecture] }]) \
\ { results \
\ { id date semester publicComment downloadable faculty { id displayName } lectures { id displayName aliases } type numPages } \
\ } \
\}"