diff --git a/govtool/backend/src/VVA/API.hs b/govtool/backend/src/VVA/API.hs index 64f6236dd..d839c2e0d 100644 --- a/govtool/backend/src/VVA/API.hs +++ b/govtool/backend/src/VVA/API.hs @@ -29,6 +29,7 @@ import Numeric.Natural (Natural) import Servant.API import Servant.Server +import System.Random (randomRIO) import Text.Read (readMaybe) @@ -153,6 +154,7 @@ drepList mSearchQuery statuses mSortMode mPage mPageSize = do let sortDReps = case mSortMode of Nothing -> id + Just Random -> sortOn (\_ -> randomRIO (0, 1 :: Double)) dreps Just VotingPower -> sortOn $ \Types.DRepRegistration {..} -> Down dRepRegistrationVotingPower Just RegistrationDate -> sortOn $ \Types.DRepRegistration {..} -> diff --git a/govtool/backend/src/VVA/API/Types.hs b/govtool/backend/src/VVA/API/Types.hs index 308c17669..0017a15dc 100644 --- a/govtool/backend/src/VVA/API/Types.hs +++ b/govtool/backend/src/VVA/API/Types.hs @@ -202,7 +202,7 @@ instance ToParamSchema GovernanceActionType where & enum_ ?~ map toJSON (enumFromTo minBound maxBound :: [GovernanceActionType]) -data DRepSortMode = VotingPower | RegistrationDate | Status deriving (Bounded, Enum, Eq, Generic, Read, Show) +data DRepSortMode = Random | VotingPower | RegistrationDate | Status deriving (Bounded, Enum, Eq, Generic, Read, Show) instance FromJSON DRepSortMode where parseJSON (Aeson.String dRepSortMode) = pure $ fromJust $ readMaybe (Text.unpack dRepSortMode) diff --git a/govtool/backend/vva-be.cabal b/govtool/backend/vva-be.cabal index b269c0e52..f53ed5258 100644 --- a/govtool/backend/vva-be.cabal +++ b/govtool/backend/vva-be.cabal @@ -103,6 +103,7 @@ library , http-client-tls , vector , async + , random exposed-modules: VVA.Config , VVA.CommandLine