Skip to content

Commit

Permalink
Merge pull request #590 from IntersectMBO/develop
Browse files Browse the repository at this point in the history
Fixes and Additions: Dashboard Loading Issue Resolved, Search Improvements, and Vote Response Enhancement
  • Loading branch information
pmbinapps authored Mar 28, 2024
2 parents f8b87b0 + a7e6742 commit 82871e7
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ changes.

### Added

- added `epochNo` and `date` to `drep/getVotes` and `proposal/get`
- Added `isRegisteredAsSoleVoter` and `wasRegisteredAsSoleVoter` fields to the drep/info response [Issue 212](https://github.com/IntersectMBO/govtool/issues/212)
- Abandoning registration as DRep [Issue 151](https://github.com/IntersectMBO/govtool/issues/151)
- Abandoning GA creation [Issue 359](https://github.com/IntersectMBO/govtool/issues/359)
Expand All @@ -44,6 +45,7 @@ changes.

### Fixed

- proposal/list search is case insensitive now [Issue 582](https://github.com/IntersectMBO/govtool/issues/582)
- proposal/list now takes optional `search` query param [Issue 566](https://github.com/IntersectMBO/govtool/issues/566)
- Fix possible sql error when there would be no predefined drep voting pwoer [Issue 501](https://github.com/IntersectMBO/govtool/issues/501)
- Fix drep type detection when changing metadata [Issue 333](https://github.com/IntersectMBO/govtool/issues/333)
Expand Down
4 changes: 3 additions & 1 deletion govtool/backend/sql/get-votes.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select DISTINCT ON (voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter) voting_procedure.gov_action_proposal_id, concat(encode(tx.hash,'hex'),'#',gov_action_proposal.index), encode(drep_hash.raw, 'hex'), voting_procedure.vote::text, voting_anchor.url, encode(voting_anchor.data_hash, 'hex')
select DISTINCT ON (voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter) voting_procedure.gov_action_proposal_id, concat(encode(tx.hash,'hex'),'#',gov_action_proposal.index), encode(drep_hash.raw, 'hex'), voting_procedure.vote::text, voting_anchor.url, encode(voting_anchor.data_hash, 'hex'), block.epoch_no as epoch_no, block.time as time
from voting_procedure
join gov_action_proposal
on gov_action_proposal.id = voting_procedure.gov_action_proposal_id
Expand All @@ -8,5 +8,7 @@ left join voting_anchor
on voting_anchor.id = voting_procedure.voting_anchor_id
join tx
on tx.id = gov_action_proposal.tx_id
join block
on block.id = tx.block_id
where drep_hash.raw = decode(?, 'hex')
order by voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter, voting_procedure.id desc
14 changes: 8 additions & 6 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ voteToResponse Types.Vote {..} =
voteParamsDrepId = HexText voteDrepId,
voteParamsVote = voteVote,
voteParamsUrl = voteUrl,
voteParamsMetadataHash = HexText <$> voteDocHash
voteParamsMetadataHash = HexText <$> voteDocHash,
voteParamsEpochNo = voteEpochNo,
voteParamsDate = voteDate
}


Expand Down Expand Up @@ -242,13 +244,13 @@ listProposals selectedTypes sortMode mPage mPageSize mDrepRaw mSearchQuery = do



let filterF ProposalResponse{..} = case mSearchQuery of
let filterF ProposalResponse{..} = case Text.toLower <$> mSearchQuery of
Nothing -> True
Just searchQuery -> fromMaybe False $ do
title <- proposalResponseTitle
about <- proposalResponseAbout
motivation <- proposalResponseMotivation
rationale <- proposalResponseRationale
title <- Text.toLower <$> proposalResponseTitle
about <- Text.toLower <$> proposalResponseAbout
motivation <- Text.toLower <$> proposalResponseMotivation
rationale <- Text.toLower <$> proposalResponseRationale

let result = searchQuery `isInfixOf` title
|| searchQuery `isInfixOf` about
Expand Down
6 changes: 5 additions & 1 deletion govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ data VoteParams
, voteParamsVote :: Text
, voteParamsUrl :: Maybe Text
, voteParamsMetadataHash :: Maybe HexText
, voteParamsEpochNo :: Integer
, voteParamsDate :: UTCTime
}
deriving (Generic, Show)

Expand All @@ -381,7 +383,9 @@ exampleVoteParams =
<> "\"drepId\": \"b4e4184bfedf920fec53cdc327de4da661ae427784c0ccca9e3c2f50\","
<> "\"vote\": \"yes\","
<> "\"url\": \"https://vote.metadata.xyz\","
<> "\"metadataHash\": \"9af10e89979e51b8cdc827c963124a1ef4920d1253eef34a1d5cfe76438e3f11\" }"
<> "\"metadataHash\": \"9af10e89979e51b8cdc827c963124a1ef4920d1253eef34a1d5cfe76438e3f11\","
<> "\"epochNo\": 0,"
<> "\"date\": \"1970-01-01T00:00:00Z\"}"

instance ToSchema VoteParams where
declareNamedSchema proxy = do
Expand Down
8 changes: 5 additions & 3 deletions govtool/backend/src/VVA/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Data.Scientific
import Data.String (fromString)
import Data.Text (Text, pack, unpack)
import qualified Data.Text.Encoding as Text
import Data.Time

import qualified Database.PostgreSQL.Simple as SQL

Expand Down Expand Up @@ -81,13 +82,14 @@ getVotes ::
getVotes drepId selectedProposals = withPool $ \conn -> do
results <- liftIO $ SQL.query conn getVotesSql (SQL.Only drepId)
let proposalsToSelect = if null selectedProposals
then [ govActionId | (_, govActionId, _, _, _, _) <- results]
then [ govActionId | (_, govActionId, _, _, _, _, _, _) <- results]
else selectedProposals
proposals <- Proposal.getProposals (Just proposalsToSelect)
let proposalMap = M.fromList $ map (\x -> (proposalId x, x)) proposals
timeZone <- liftIO getCurrentTimeZone
return
([ Vote proposalId' drepId' vote' url' docHash'
| (proposalId', govActionId', drepId', vote', url', docHash') <- results
([ Vote proposalId' drepId' vote' url' docHash' epochNo' (localTimeToUTC timeZone date')
| (proposalId', govActionId', drepId', vote', url', docHash', epochNo', date') <- results
, govActionId' `elem` proposalsToSelect
], proposals)

Expand Down
2 changes: 2 additions & 0 deletions govtool/backend/src/VVA/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ data Vote
, voteVote :: Text
, voteUrl :: Maybe Text
, voteDocHash :: Maybe Text
, voteEpochNo :: Integer
, voteDate :: UTCTime
}

data DRepInfo
Expand Down
6 changes: 5 additions & 1 deletion govtool/frontend/src/components/organisms/DashboardCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export const DashboardCards = () => {
const { votingPower } = useGetAdaHolderVotingPowerQuery(stakeKey);
const { voter } = useGetVoterInfo();

if (!currentDelegation || !voter || !votingPower) {
if (
currentDelegation === undefined
|| votingPower === undefined
|| voter === undefined
) {
return (
<Box
sx={{
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/components/organisms/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const Slider = ({
alignItems: "center",
gap: "10px",
mb: 3.5,
height: "46px",
}}
>
<Box
Expand Down

0 comments on commit 82871e7

Please sign in to comment.