From 482241d033c32c52c31ea20920a4fec07ba975dd Mon Sep 17 00:00:00 2001 From: ros Date: Fri, 2 Jul 2021 14:32:13 +0200 Subject: [PATCH 1/3] feat(sorting tutorial table): done --- src/Application.hs | 2 +- src/Handler/Tutorial/List.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Application.hs b/src/Application.hs index 7d02e6009..54213df10 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -718,4 +718,4 @@ addPWEntry :: User addPWEntry User{ userAuthentication = _, ..} (Text.encodeUtf8 -> pw) = db' $ do PWHashConf{..} <- getsYesod $ view _appAuthPWHash (AuthPWHash . Text.decodeUtf8 -> userAuthentication) <- liftIO $ makePasswordWith pwHashAlgorithm pw pwHashStrength - void $ insert User{..} + void $ insert User{..} \ No newline at end of file diff --git a/src/Handler/Tutorial/List.hs b/src/Handler/Tutorial/List.hs index 39f67c0e8..b49eea883 100644 --- a/src/Handler/Tutorial/List.hs +++ b/src/Handler/Tutorial/List.hs @@ -42,7 +42,7 @@ getCTutorialListR tid ssh csh = do dbtColonnade = dbColonnade $ mconcat [ sortable (Just "type") (i18nCell MsgTableTutorialType) $ \(view $ resultTutorial . _entityVal -> Tutorial{..}) -> textCell $ CI.original tutorialType , sortable (Just "name") (i18nCell MsgTableTutorialName) $ \(view $ resultTutorial . _entityVal -> Tutorial{..}) -> anchorCell (CTutorialR tid ssh csh tutorialName TUsersR) [whamlet|#{tutorialName}|] - , sortable Nothing (i18nCell MsgTableTutorialTutors) $ \(view $ resultTutorial . _entityKey -> tutid) -> sqlCell $ do + , sortable (Just "tutors") (i18nCell MsgTableTutorialTutors) $ \(view $ resultTutorial . _entityKey -> tutid) -> sqlCell $ do tutors <- fmap (map $(unValueN 3)) . E.select . E.from $ \(tutor `E.InnerJoin` user) -> do E.on $ tutor E.^. TutorUser E.==. user E.^. UserId E.where_ $ tutor E.^. TutorTutorial E.==. E.val tutid From b1787cd77e8a643accc0ef54cc18c87df215680c Mon Sep 17 00:00:00 2001 From: ros Date: Thu, 8 Jul 2021 11:14:22 +0200 Subject: [PATCH 2/3] feat(tutor tabel sorting): dbt sorting tutors added --- src/Handler/Tutorial/List.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Handler/Tutorial/List.hs b/src/Handler/Tutorial/List.hs index b49eea883..9043cb08d 100644 --- a/src/Handler/Tutorial/List.hs +++ b/src/Handler/Tutorial/List.hs @@ -71,6 +71,12 @@ getCTutorialListR tid ssh csh = do dbtSorting = Map.fromList [ ("type", SortColumn $ \tutorial -> tutorial E.^. TutorialType ) , ("name", SortColumn $ \tutorial -> tutorial E.^. TutorialName ) + , ( "tutors" + , SortColumn $ \tutorial -> E.subSelectMaybe . E.from $ \(tutor `E.InnerJoin` user) -> do + E.on $ tutor E.^. TutorUser E.==. user E.^. UserId + E.where_ $ tutorial E.^. TutorialId E.==. tutor E.^. TutorTutorial + return . E.min_ $ user E.^. UserSurname + ) , ("participants", SortColumn $ \tutorial -> let participantCount :: E.SqlExpr (E.Value Int) participantCount = E.subSelectCount . E.from $ \tutorialParticipant -> E.where_ $ tutorialParticipant E.^. TutorialParticipantTutorial E.==. tutorial E.^. TutorialId From 9dc12de056e73736659c053b0eabef66ca524047 Mon Sep 17 00:00:00 2001 From: ros Date: Tue, 17 Aug 2021 11:46:54 +0200 Subject: [PATCH 3/3] feat(sorting tutorial table): application restore --- src/Application.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application.hs b/src/Application.hs index 54213df10..7d02e6009 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -718,4 +718,4 @@ addPWEntry :: User addPWEntry User{ userAuthentication = _, ..} (Text.encodeUtf8 -> pw) = db' $ do PWHashConf{..} <- getsYesod $ view _appAuthPWHash (AuthPWHash . Text.decodeUtf8 -> userAuthentication) <- liftIO $ makePasswordWith pwHashAlgorithm pw pwHashStrength - void $ insert User{..} \ No newline at end of file + void $ insert User{..}