From 3fddbc6a1d7f449dc8dc184a9fba27bdb1bb64cb Mon Sep 17 00:00:00 2001 From: Adam Tomaszczyk Date: Thu, 28 Aug 2025 13:47:07 +0200 Subject: [PATCH] Even more DRep search improvements #4030 --- govtool/backend/app/Main.hs | 3 +- govtool/backend/example-config.json | 1 + govtool/backend/src/VVA/Config.hs | 34 +++++++++++-------- .../components/molecules/PaginationFooter.tsx | 23 ++++++++++++- 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/govtool/backend/app/Main.hs b/govtool/backend/app/Main.hs index 4ba525ad0..522b40bb6 100644 --- a/govtool/backend/app/Main.hs +++ b/govtool/backend/app/Main.hs @@ -115,6 +115,7 @@ startApp vvaConfig sentryService = do $ setOnException (exceptionHandler vvaConfig sentryService) defaultSettings cacheEnv <- do let newCache = Cache.newCache (Just $ TimeSpec (fromIntegral (cacheDurationSeconds vvaConfig)) 0) + let newDRepListCache = Cache.newCache (Just $ TimeSpec (fromIntegral (dRepListCacheDurationSeconds vvaConfig)) 0) proposalListCache <- newCache getProposalCache <- newCache currentEpochCache <- newCache @@ -123,7 +124,7 @@ startApp vvaConfig sentryService = do dRepGetVotesCache <- newCache dRepInfoCache <- newCache dRepVotingPowerCache <- newCache - dRepListCache <- newCache + dRepListCache <- newDRepListCache networkMetricsCache <- newCache networkInfoCache <- newCache networkTotalStakeCache <- newCache diff --git a/govtool/backend/example-config.json b/govtool/backend/example-config.json index 800f7dde1..7cfb4d5f2 100644 --- a/govtool/backend/example-config.json +++ b/govtool/backend/example-config.json @@ -10,6 +10,7 @@ "port" : 9999, "host" : "localhost", "cachedurationseconds": 20, + "dreplistcachedurationseconds": 600, "sentrydsn": "https://username:password@senty.host/id", "sentryenv": "dev" } diff --git a/govtool/backend/src/VVA/Config.hs b/govtool/backend/src/VVA/Config.hs index 997a3c231..b11358f3d 100644 --- a/govtool/backend/src/VVA/Config.hs +++ b/govtool/backend/src/VVA/Config.hs @@ -68,19 +68,21 @@ instance DefaultConfig DBConfig where data VVAConfigInternal = VVAConfigInternal { -- | db-sync database access. - vVAConfigInternalDbsyncconfig :: DBConfig + vVAConfigInternalDbsyncconfig :: DBConfig -- | Server port. - , vVAConfigInternalPort :: Int + , vVAConfigInternalPort :: Int -- | Server host. - , vVAConfigInternalHost :: Text + , vVAConfigInternalHost :: Text -- | Request cache duration - , vVaConfigInternalCacheDurationSeconds :: Int + , vVaConfigInternalCacheDurationSeconds :: Int + -- | DRep List request cache duration + , vVaConfigInternalDRepListCacheDurationSeconds :: Int -- | Sentry DSN - , vVAConfigInternalSentrydsn :: String + , vVAConfigInternalSentrydsn :: String -- | Sentry environment - , vVAConfigInternalSentryEnv :: String + , vVAConfigInternalSentryEnv :: String -- | Pinata API JWT - , vVAConfigInternalPinataApiJwt :: Maybe Text + , vVAConfigInternalPinataApiJwt :: Maybe Text } deriving (FromConfig, Generic, Show) @@ -92,6 +94,7 @@ instance DefaultConfig VVAConfigInternal where vVAConfigInternalPort = 3000, vVAConfigInternalHost = "localhost", vVaConfigInternalCacheDurationSeconds = 20, + vVaConfigInternalDRepListCacheDurationSeconds = 600, vVAConfigInternalSentrydsn = "https://username:password@senty.host/id", vVAConfigInternalSentryEnv = "development", vVAConfigInternalPinataApiJwt = Nothing @@ -101,19 +104,21 @@ instance DefaultConfig VVAConfigInternal where data VVAConfig = VVAConfig { -- | db-sync database credentials. - dbSyncConnectionString :: Text + dbSyncConnectionString :: Text -- | Server port. - , serverPort :: Int + , serverPort :: Int -- | Server host. - , serverHost :: Text + , serverHost :: Text -- | Request cache duration - , cacheDurationSeconds :: Int + , cacheDurationSeconds :: Int + -- | DRep List request cache duration + , dRepListCacheDurationSeconds :: Int -- | Sentry DSN - , sentryDSN :: String + , sentryDSN :: String -- | Sentry environment - , sentryEnv :: String + , sentryEnv :: String -- | Pinata API JWT - , pinataApiJwt :: Maybe Text + , pinataApiJwt :: Maybe Text } deriving (Generic, Show, ToJSON) @@ -153,6 +158,7 @@ convertConfig VVAConfigInternal {..} = serverPort = vVAConfigInternalPort, serverHost = vVAConfigInternalHost, cacheDurationSeconds = vVaConfigInternalCacheDurationSeconds, + dRepListCacheDurationSeconds = vVaConfigInternalDRepListCacheDurationSeconds, sentryDSN = vVAConfigInternalSentrydsn, sentryEnv = vVAConfigInternalSentryEnv, pinataApiJwt = vVAConfigInternalPinataApiJwt diff --git a/govtool/frontend/src/components/molecules/PaginationFooter.tsx b/govtool/frontend/src/components/molecules/PaginationFooter.tsx index 77a751105..55f66cabf 100644 --- a/govtool/frontend/src/components/molecules/PaginationFooter.tsx +++ b/govtool/frontend/src/components/molecules/PaginationFooter.tsx @@ -8,7 +8,8 @@ import { } from "@mui/material"; import KeyboardArrowLeft from "@mui/icons-material/KeyboardArrowLeft"; import KeyboardArrowRight from "@mui/icons-material/KeyboardArrowRight"; -import { FC } from "react"; +import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown"; +import { FC, useState } from "react"; type Props = { page: number; @@ -46,6 +47,19 @@ export const PaginationFooter: FC = ({ } }; + const [open, setOpen] = useState(false); + + const ArrowIcon: React.FC> = (props,) => ( + ) => { + e.preventDefault(); + e.stopPropagation(); + setOpen(true); + }} + /> + ); + return ( = ({ onChange={handlePageSizeChange} variant="standard" disableUnderline + open={open} + onOpen={() => setOpen(true)} + onClose={() => setOpen(false)} + IconComponent={ArrowIcon} sx={{ verticalAlign: "baseline", "& .MuiSelect-select": { py: 0, + pr: "8px !important", lineHeight: 1.5, display: "inline-flex", alignItems: "center", }, "& .MuiSelect-icon": { + pointerEvents: "auto", + cursor: "pointer", top: "calc(50% - 12px)", }, }}