From a415aba7cce34f9adcdbf74b59aacd46b3598a48 Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Wed, 27 Mar 2024 17:38:10 +0100 Subject: [PATCH 1/5] [#541] fix dashboard infinite loading --- .../frontend/src/components/organisms/DashboardCards.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/govtool/frontend/src/components/organisms/DashboardCards.tsx b/govtool/frontend/src/components/organisms/DashboardCards.tsx index ec7747cf3..5ba437c4a 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards.tsx @@ -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 ( Date: Thu, 28 Mar 2024 10:33:15 +0100 Subject: [PATCH 2/5] Slider styles tiny fix --- govtool/frontend/src/components/organisms/Slider.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/govtool/frontend/src/components/organisms/Slider.tsx b/govtool/frontend/src/components/organisms/Slider.tsx index 6be504364..577e8f9e8 100644 --- a/govtool/frontend/src/components/organisms/Slider.tsx +++ b/govtool/frontend/src/components/organisms/Slider.tsx @@ -102,6 +102,7 @@ export const Slider = ({ alignItems: "center", gap: "10px", mb: 3.5, + height: "46px", }} > Date: Thu, 28 Mar 2024 12:42:20 +0100 Subject: [PATCH 3/5] [#586] add epochNo and date to vote response Signed-off-by: jankun4 --- govtool/backend/sql/get-votes.sql | 4 +++- govtool/backend/src/VVA/API.hs | 4 +++- govtool/backend/src/VVA/API/Types.hs | 6 +++++- govtool/backend/src/VVA/DRep.hs | 8 +++++--- govtool/backend/src/VVA/Types.hs | 2 ++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/govtool/backend/sql/get-votes.sql b/govtool/backend/sql/get-votes.sql index 30dc5fc2b..18ff422fd 100644 --- a/govtool/backend/sql/get-votes.sql +++ b/govtool/backend/sql/get-votes.sql @@ -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 @@ -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 diff --git a/govtool/backend/src/VVA/API.hs b/govtool/backend/src/VVA/API.hs index 3796b52d3..c215e0486 100644 --- a/govtool/backend/src/VVA/API.hs +++ b/govtool/backend/src/VVA/API.hs @@ -149,7 +149,9 @@ voteToResponse Types.Vote {..} = voteParamsDrepId = HexText voteDrepId, voteParamsVote = voteVote, voteParamsUrl = voteUrl, - voteParamsMetadataHash = HexText <$> voteDocHash + voteParamsMetadataHash = HexText <$> voteDocHash, + voteParamsEpochNo = voteEpochNo, + voteParamsDate = voteDate } diff --git a/govtool/backend/src/VVA/API/Types.hs b/govtool/backend/src/VVA/API/Types.hs index 83352c56e..a591305b6 100644 --- a/govtool/backend/src/VVA/API/Types.hs +++ b/govtool/backend/src/VVA/API/Types.hs @@ -370,6 +370,8 @@ data VoteParams , voteParamsVote :: Text , voteParamsUrl :: Maybe Text , voteParamsMetadataHash :: Maybe HexText + , voteParamsEpochNo :: Integer + , voteParamsDate :: UTCTime } deriving (Generic, Show) @@ -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 diff --git a/govtool/backend/src/VVA/DRep.hs b/govtool/backend/src/VVA/DRep.hs index 52008a2cd..eede66a81 100644 --- a/govtool/backend/src/VVA/DRep.hs +++ b/govtool/backend/src/VVA/DRep.hs @@ -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 @@ -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) diff --git a/govtool/backend/src/VVA/Types.hs b/govtool/backend/src/VVA/Types.hs index a741489be..15ac3595f 100644 --- a/govtool/backend/src/VVA/Types.hs +++ b/govtool/backend/src/VVA/Types.hs @@ -60,6 +60,8 @@ data Vote , voteVote :: Text , voteUrl :: Maybe Text , voteDocHash :: Maybe Text + , voteEpochNo :: Integer + , voteDate :: UTCTime } data DRepInfo From 75dbcb9eb7e025988e082f50289509e5bbc08695 Mon Sep 17 00:00:00 2001 From: jankun4 Date: Thu, 28 Mar 2024 12:45:01 +0100 Subject: [PATCH 4/5] [#586] update changelog Signed-off-by: jankun4 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aeab28c58..d732296c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) From a7e674262debd14e3426a2edc4189e63110961ad Mon Sep 17 00:00:00 2001 From: jankun4 Date: Thu, 28 Mar 2024 00:56:09 +0100 Subject: [PATCH 5/5] [#582] make proposal/list search case insensitive Signed-off-by: jankun4 --- CHANGELOG.md | 1 + govtool/backend/src/VVA/API.hs | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d732296c7..ec7a3913b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,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) diff --git a/govtool/backend/src/VVA/API.hs b/govtool/backend/src/VVA/API.hs index c215e0486..6072be08f 100644 --- a/govtool/backend/src/VVA/API.hs +++ b/govtool/backend/src/VVA/API.hs @@ -244,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