fix(firm): supervisor filter acts weird in test environment

no cause discerned, test in dev evironment were all fine. Maybe the sorting assumption wasn't right?

note other filters do not interfere with the memcaching in experiments
This commit is contained in:
Steffen Jost 2023-12-21 17:26:46 +01:00
parent decc5af682
commit b566e59eb1

View File

@ -599,7 +599,7 @@ mkFirmAllTable isAdmin uid = do
case criterion of case criterion of
Nothing -> return True :: DB Bool Nothing -> return True :: DB Bool
(Just (crit::Text)) -> do (Just (crit::Text)) -> do
critFirms <- memcachedBy (Just . Right $ 5 * diffMinute) ("svr:"<>crit) $ fmap (Set.fromAscList . fmap E.unValue) $ E.select $ E.distinct $ do critFirms <- memcachedBy (Just . Right $ 1 * diffMinute) ("SVR:"<>crit) $ fmap (Set.fromList . fmap E.unValue) $ E.select $ E.distinct $ do
(usr :& cmp) <- E.from $ E.table @User `E.innerJoin` E.table @Company (usr :& cmp) <- E.from $ E.table @User `E.innerJoin` E.table @Company
`E.on` (\(usr :& cmp) -> E.exists (do `E.on` (\(usr :& cmp) -> E.exists (do
usrCmp <- E.from $ E.table @UserCompany usrCmp <- E.from $ E.table @UserCompany
@ -612,13 +612,13 @@ mkFirmAllTable isAdmin uid = do
E.&&. E.exists (do E.&&. E.exists (do
usrSub <- E.from $ E.table @UserCompany usrSub <- E.from $ E.table @UserCompany
E.where_ $ usrSub E.^. UserCompanyUser E.==. usrSpr E.^. UserSupervisorUser E.where_ $ usrSub E.^. UserCompanyUser E.==. usrSpr E.^. UserSupervisorUser
E.&&. usrSub E.^. UserCompanyCompany E.==. cmp E.^. CompanyId E.&&. usrSub E.^. UserCompanyCompany E.==. cmp E.^. CompanyId
) )
)) ))
E.where_ $ (usr E.^. UserDisplayName `E.hasInfix` E.val crit) E.where_ $ (usr E.^. UserDisplayName `E.hasInfix` E.val crit )
E.||. (usr E.^. UserDisplayEmail `E.hasInfix` E.val (CI.mk crit)) E.||. (usr E.^. UserDisplayEmail `E.hasInfix` E.val (CI.mk crit))
E.||. (usr E.^. UserSurname `E.hasInfix` E.val crit) E.||. (usr E.^. UserSurname `E.hasInfix` E.val crit )
E.orderBy [E.asc $ cmp E.^. CompanyId] -- E.orderBy [E.asc $ cmp E.^. CompanyId]
return $ cmp E.^. CompanyId return $ cmp E.^. CompanyId
let cid = dbr ^. resultAllCompanyEntity . _entityKey let cid = dbr ^. resultAllCompanyEntity . _entityKey
return $ Set.member cid critFirms return $ Set.member cid critFirms