Favourites are pruned now
This commit is contained in:
parent
2dde6c67bc
commit
272c61b512
@ -38,7 +38,9 @@ ldap:
|
|||||||
password: "_env:LDAPPW:"
|
password: "_env:LDAPPW:"
|
||||||
basename: "_env:LDAPBN:"
|
basename: "_env:LDAPBN:"
|
||||||
|
|
||||||
|
userDefaultFavourites: 12
|
||||||
|
|
||||||
cryptoid-keyfile: "_env:CRYPTOID_KEYFILE:cryptoid_key.bf"
|
cryptoid-keyfile: "_env:CRYPTOID_KEYFILE:cryptoid_key.bf"
|
||||||
|
|
||||||
copyright: Insert copyright statement here
|
copyright: ©Institute for Informatics, LMU Munich
|
||||||
#analytics: UA-YOURCODE
|
#analytics: UA-YOURCODE
|
||||||
|
|||||||
1
models
1
models
@ -4,6 +4,7 @@ User
|
|||||||
matrikelnummer Text Maybe
|
matrikelnummer Text Maybe
|
||||||
email Text
|
email Text
|
||||||
displayName Text
|
displayName Text
|
||||||
|
maxFavourites Int default=12
|
||||||
UniqueAuthentication plugin ident
|
UniqueAuthentication plugin ident
|
||||||
UserAdmin
|
UserAdmin
|
||||||
user UserId
|
user UserId
|
||||||
|
|||||||
@ -155,11 +155,20 @@ instance Yesod UniWorX where
|
|||||||
uid <- MaybeT maybeAuthId
|
uid <- MaybeT maybeAuthId
|
||||||
now <- liftIO $ getCurrentTime
|
now <- liftIO $ getCurrentTime
|
||||||
void . lift . runDB . runMaybeT $ do
|
void . lift . runDB . runMaybeT $ do
|
||||||
cid <- MaybeT . getKeyBy $ CourseTermShort tid csh
|
cid <- MaybeT . getKeyBy $ CourseTermShort tid csh
|
||||||
|
user <- MaybeT $ get uid
|
||||||
|
-- update Favorites
|
||||||
lift $ upsertBy
|
lift $ upsertBy
|
||||||
(UniqueCourseFavourite uid cid)
|
(UniqueCourseFavourite uid cid)
|
||||||
(CourseFavourite uid now cid)
|
(CourseFavourite uid now cid)
|
||||||
[CourseFavouriteTime =. now]
|
[CourseFavouriteTime =. now]
|
||||||
|
-- prune Favorites to user-defined size
|
||||||
|
oldFavs <- lift $ selectKeysList
|
||||||
|
[ CourseFavouriteUser ==. uid]
|
||||||
|
[ Desc CourseFavouriteTime
|
||||||
|
, OffsetBy $ userMaxFavourites user
|
||||||
|
]
|
||||||
|
lift $ mapM delete oldFavs
|
||||||
|
|
||||||
_other -> return ()
|
_other -> return ()
|
||||||
return res
|
return res
|
||||||
@ -479,6 +488,7 @@ instance YesodAuth UniWorX where
|
|||||||
userDisplayName <- maybe (throwError $ ServerError "Could not retrieve user name") return userDisplayName'
|
userDisplayName <- maybe (throwError $ ServerError "Could not retrieve user name") return userDisplayName'
|
||||||
|
|
||||||
let
|
let
|
||||||
|
userMaxFavourites = 12 -- TODO: appDefaultFavourites appSettings
|
||||||
newUser = User{..}
|
newUser = User{..}
|
||||||
userUpdate = [ UserMatrikelnummer =. userMatrikelnummer
|
userUpdate = [ UserMatrikelnummer =. userMatrikelnummer
|
||||||
, UserDisplayName =. userDisplayName
|
, UserDisplayName =. userDisplayName
|
||||||
|
|||||||
@ -59,6 +59,9 @@ data AppSettings = AppSettings
|
|||||||
, appSkipCombining :: Bool
|
, appSkipCombining :: Bool
|
||||||
-- ^ Perform no stylesheet/script combining
|
-- ^ Perform no stylesheet/script combining
|
||||||
|
|
||||||
|
, appDefaultFavourites :: Int
|
||||||
|
-- ^ Initial Value for remembered Favourites
|
||||||
|
|
||||||
-- Example app-specific configuration values.
|
-- Example app-specific configuration values.
|
||||||
, appCopyright :: Text
|
, appCopyright :: Text
|
||||||
-- ^ Copyright text to appear in the footer of the page
|
-- ^ Copyright text to appear in the footer of the page
|
||||||
@ -94,6 +97,8 @@ instance FromJSON AppSettings where
|
|||||||
appMutableStatic <- o .:? "mutable-static" .!= defaultDev
|
appMutableStatic <- o .:? "mutable-static" .!= defaultDev
|
||||||
appSkipCombining <- o .:? "skip-combining" .!= defaultDev
|
appSkipCombining <- o .:? "skip-combining" .!= defaultDev
|
||||||
|
|
||||||
|
appDefaultFavourites <- o .: "userDefaultFavourites"
|
||||||
|
|
||||||
appCopyright <- o .: "copyright"
|
appCopyright <- o .: "copyright"
|
||||||
appAnalytics <- o .:? "analytics"
|
appAnalytics <- o .:? "analytics"
|
||||||
appCryptoIDKeyFile <- o .: "cryptoid-keyfile"
|
appCryptoIDKeyFile <- o .: "cryptoid-keyfile"
|
||||||
|
|||||||
Reference in New Issue
Block a user