chore(dbtable): moved async table threshold to config

This commit is contained in:
David Mosbach 2024-06-17 00:31:21 +00:00
parent 5aa1cf7147
commit 9661c58b4d
3 changed files with 13 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>,Wolfgang Witt <Wolfgang.Witt@campus.lmu.de>
# SPDX-FileCopyrightText: 2022-2024 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>,Wolfgang Witt <Wolfgang.Witt@campus.lmu.de>,David Mosbach <david.mosbach@uniworx.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
@ -339,3 +339,5 @@ bot-mitigations:
volatile-cluster-settings-cache-time: 10
communication-attachments-max-size: 20971520 # 20MiB
async-table-max-rows: 500

View File

@ -650,7 +650,6 @@ defaultDBSFilterLayout filterWdgt filterEnctype filterAction scrolltable
, formSubmit = FormSubmit --FormAutoSubmit --TODO not for sync-tables
, formAnchor = Nothing :: Maybe Text
}
syncButton = [whamlet|<div>|]-- [whamlet|<button>Apply Filter|] --TODO i18n & don't show in async-tables
singletonFilter :: Ord k => k -> Prism' (Map k [v]) (Maybe v)
@ -1643,15 +1642,17 @@ dbTable PSValidator{..} dbtable@DBTable{ dbtIdent = dbtIdent'@(toPathPiece -> db
redirect $ tblLink id
(act, _) -> act
AppSettings{..} <- getsYesod appSettings'
let
maxRows = 2
maxRows = fromIntegral @Natural @Int $ fromMaybe 0 appAsyncTableMaxRows
wrapLayout :: DBResult m x -> DB (DBResult m x)
wrapLayout = dbHandler (Proxy @m) (Proxy @x) $ (\table -> $(widgetFile "table/layout-wrapper")) . uiLayout
selector :: (Text, Text)
selector
| null rows && (dbsEmptyStyle == DBESNoHeading) = ("","")
| length rows >= maxRows = ("uw-sync-table","")
| otherwise = ("uw-async-table","") --TODO only for small tables
| length rows > maxRows = ("uw-sync-table","")
| otherwise = ("uw-async-table","")
shortcircuit :: forall void. DBResult m x -> DB void
shortcircuit res = do
addCustomHeader HeaderDBTableCanonicalURL =<< toTextUrl (tblLink substPi)

View File

@ -1,4 +1,4 @@
-- SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>
-- SPDX-FileCopyrightText: 2022-2024 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>,David Mosbach <david.mosbach@uniworx.de>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later
@ -251,6 +251,8 @@ data AppSettings = AppSettings
, appFileChunkingParams :: FastCDCParameters
, appLegalExternal :: Set LegalExternal
, appAsyncTableMaxRows :: Maybe Natural
} deriving Show
@ -817,6 +819,8 @@ instance FromJSON AppSettings where
appLegalExternal <- o .: "legal-external"
appAsyncTableMaxRows <- o .: "async-table-max-rows"
return AppSettings{..}
where isValidARCConf ARCConf{..} = arccMaximumWeight > 0