From b89dd09a948e1deeb113a64be8f04cb7b28c7630 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 17 Oct 2018 09:47:54 +0200 Subject: [PATCH 1/4] NTSheetInactive should default to False --- src/Model/Types.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Types.hs b/src/Model/Types.hs index b1e98b0b6..19ff99f5b 100644 --- a/src/Model/Types.hs +++ b/src/Model/Types.hs @@ -514,7 +514,7 @@ instance Default NotificationSettings where NTSubmissionRatedGraded -> True NTSubmissionRated -> False NTSheetActive -> True - NTSheetInactive -> True + NTSheetInactive -> False instance ToJSON NotificationSettings where toJSON v = toJSON . HashMap.fromList $ map (id &&& notificationAllowed v) universeF From 84be8ee7e597ea37beee8e8d1381262fcd03741c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 17 Oct 2018 10:16:08 +0200 Subject: [PATCH 2/4] Fix db.hs --- db.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db.hs b/db.hs index adf008619..dc5ed8f3d 100755 --- a/db.hs +++ b/db.hs @@ -195,8 +195,8 @@ fillDb = do let sdInf = StudyTermsKey' 79 sdMath = StudyTermsKey' 105 - repsert sdInf $ StudyTerms 79 (Just "Inf") (Just "Informatik") - repsert sdMath $ StudyTerms 105 (Just "M" ) (Just "Mathematik") + repsert sdInf $ StudyTerms 79 (Just "IfI") (Just "Institut für Informatik") + repsert sdMath $ StudyTerms 105 (Just "MI" ) (Just "Mathematisches Institut") -- FFP ffp <- insert' Course { courseName = "Fortgeschrittene Funktionale Programmierung" @@ -217,11 +217,11 @@ fillDb = do void . insert $ DegreeCourse ffp sdMst sdInf void . insert $ Lecturer jost ffp void . insert $ Lecturer gkleen ffp - sheetkey <- insert $ Sheet ffp "AdHoc-Gruppen" Nothing NotGraded (Arbitrary 3) Nothing Nothing now now Nothing Nothing (Upload True) + sheetkey <- insert $ Sheet ffp "AdHoc-Gruppen" Nothing NotGraded (Arbitrary 3) Nothing Nothing now now Nothing Nothing (Upload True) UserSubmissions insert_ $ SheetEdit gkleen now sheetkey - sheetkey <- insert $ Sheet ffp "Feste Gruppen" Nothing NotGraded RegisteredGroups Nothing Nothing now now Nothing Nothing (Upload True) + sheetkey <- insert $ Sheet ffp "Feste Gruppen" Nothing NotGraded RegisteredGroups Nothing Nothing now now Nothing Nothing (Upload True) UserSubmissions insert_ $ SheetEdit gkleen now sheetkey - sheetkey <- insert $ Sheet ffp "Keine Gruppen" Nothing NotGraded NoGroups Nothing Nothing now now Nothing Nothing (Upload True) + sheetkey <- insert $ Sheet ffp "Keine Gruppen" Nothing NotGraded NoGroups Nothing Nothing now now Nothing Nothing (Upload True) UserSubmissions insert_ $ SheetEdit gkleen now sheetkey -- EIP eip <- insert' Course @@ -305,6 +305,7 @@ fillDb = do , sheetVisibleFrom = Just now , sheetActiveFrom = now , sheetActiveTo = (14 * nominalDay) `addUTCTime` now + , sheetSubmissionMode = CorrectorSubmissions , sheetUploadMode = Upload True , sheetHintFrom = Nothing , sheetSolutionFrom = Nothing From 36b512d90b0b55d815d08f7b86599322d046893d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 17 Oct 2018 10:19:20 +0200 Subject: [PATCH 3/4] Minor cleanup --- db.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db.hs b/db.hs index dc5ed8f3d..a58d443fa 100755 --- a/db.hs +++ b/db.hs @@ -207,7 +207,7 @@ fillDb = do , courseSchool = ifi , courseCapacity = Just 20 , courseRegisterFrom = Just now - , courseRegisterTo = Just ((3600 * 24 * 60) `addUTCTime` now ) + , courseRegisterTo = Just (nominalDay `addUTCTime` now ) , courseDeregisterUntil = Nothing , courseRegisterSecret = Nothing , courseMaterialFree = True @@ -251,7 +251,7 @@ fillDb = do , courseSchool = ifi , courseCapacity = Just 20 , courseRegisterFrom = Just now - , courseRegisterTo = Just ((3600 * 24 * 60) `addUTCTime` now ) + , courseRegisterTo = Just (nominalDay `addUTCTime` now ) , courseDeregisterUntil = Nothing , courseRegisterSecret = Nothing , courseMaterialFree = True From 52d6c2d3472d3a64998ad0c5c789f136b9b8ce2d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 17 Oct 2018 10:30:28 +0200 Subject: [PATCH 4/4] minor cleanup --- src/Utils/Sql.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Utils/Sql.hs b/src/Utils/Sql.hs index 5e456bc28..6cdb0a144 100644 --- a/src/Utils/Sql.hs +++ b/src/Utils/Sql.hs @@ -17,6 +17,8 @@ import Database.Persist.Sql import Database.PostgreSQL.Simple (sqlErrorHint) import Control.Monad.Catch (handleIf) +import Data.Time.Clock + setSerializable :: (MonadLogger m, MonadCatch m, MonadBase IO m, MonadIO m) => ReaderT SqlBackend m a -> ReaderT SqlBackend m a setSerializable act = setSerializable' (0 :: Integer) where @@ -24,7 +26,14 @@ setSerializable act = setSerializable' (0 :: Integer) setSerializable' (min 10 -> logBackoff) = handleIf - (\e -> sqlErrorHint e == "The transaction might succeed if retried.") - (\e -> $logWarnS "Sql" (tshow e) *> threadDelay (1e3 * 2 ^ logBackoff) *> setSerializable' (succ logBackoff)) + (\e -> "The transaction might succeed if retried." `isInfixOf` sqlErrorHint e) + (\e -> do + let + delay :: NominalDiffTime + delay = 1e-3 * 2 ^ logBackoff + $logWarnS "Sql" $ tshow (delay, e) + threadDelay . round $ delay * 1e6 + setSerializable' (succ logBackoff) + ) act'