Skip to content

Commit

Permalink
Merge pull request #2298 from IntersectMBO/staging
Browse files Browse the repository at this point in the history
fix: fix searching by drep name
  • Loading branch information
MSzalowski authored Oct 31, 2024
2 parents 9550c2b + 274d37b commit feadc30
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ changes.

### Fixed

-
- Fix searching by DRep Given name
- Fix displaying the wallet connected modal

### Changed

Expand Down
18 changes: 12 additions & 6 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,21 @@ delegationToResponse Types.Delegation {..} =
drepList :: App m => Maybe Text -> [DRepStatus] -> Maybe DRepSortMode -> Maybe Natural -> Maybe Natural -> m ListDRepsResponse
drepList mSearchQuery statuses mSortMode mPage mPageSize = do
CacheEnv {dRepListCache} <- asks vvaCache
dreps <- cacheRequest dRepListCache () (DRep.listDReps mSearchQuery)
dreps <- cacheRequest dRepListCache (fromMaybe "" mSearchQuery) (DRep.listDReps mSearchQuery)

let filterDRepsByQuery = case mSearchQuery of
Nothing -> filter $ \Types.DRepRegistration {..} -> dRepRegistrationType == Types.DRep
Nothing -> filter $ \Types.DRepRegistration {..} ->
dRepRegistrationType == Types.DRep
Just query -> filter $ \Types.DRepRegistration {..} ->
case dRepRegistrationType of
Types.SoleVoter -> query == dRepRegistrationView || query == dRepRegistrationDRepHash
Types.DRep -> query `isInfixOf` dRepRegistrationView
|| query `isInfixOf` dRepRegistrationDRepHash
let searchLower = Text.toLower query
viewLower = Text.toLower dRepRegistrationView
hashLower = Text.toLower dRepRegistrationDRepHash
nameLower = maybe "" Text.toLower dRepRegistrationGivenName
in case dRepRegistrationType of
Types.SoleVoter -> searchLower == viewLower || searchLower == hashLower
Types.DRep -> searchLower `isInfixOf` viewLower
|| searchLower `isInfixOf` hashLower
|| searchLower `isInfixOf` nameLower

let filterDRepsByStatus = case statuses of
[] -> id
Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/src/VVA/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ data CacheEnv
, dRepGetVotesCache :: Cache.Cache Text ([Vote], [Proposal])
, dRepInfoCache :: Cache.Cache Text DRepInfo
, dRepVotingPowerCache :: Cache.Cache Text Integer
, dRepListCache :: Cache.Cache () [DRepRegistration]
, dRepListCache :: Cache.Cache Text [DRepRegistration]
, networkMetricsCache :: Cache.Cache () NetworkMetrics
}

Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/src/context/dataActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
);

return (
<DataActionsBarContext.Provider value={contextValue} key={pathname}>
<DataActionsBarContext.Provider value={contextValue}>
{children}
</DataActionsBarContext.Provider>
);
Expand Down

0 comments on commit feadc30

Please sign in to comment.