Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GovTool v1.0.23 #2271

Merged
merged 38 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
64aa6a7
chore: remove Cypress test and Test-Metrics API
kneerose Oct 23, 2024
139244d
change: no DRep found copy text
Ryun1 Oct 23, 2024
01653ed
Update govtool/frontend/src/i18n/locales/en.ts
Ryun1 Oct 23, 2024
a0f2b79
Update govtool/frontend/src/i18n/locales/en.ts
Ryun1 Oct 23, 2024
06e716b
fix(#2233): enforce validating metadata against the specified standard
MSzalowski Oct 25, 2024
6509cd8
Merge pull request #2199 from IntersectMBO/cleanup/remove-test-metric…
kneerose Oct 28, 2024
68320f9
chore: add 128 words validation on invalid url
kneerose Oct 28, 2024
d83227f
chore: update the assertion of metadata anchor error
kneerose Oct 28, 2024
0d497da
chore: add validation for 128-word limit on metadata anchor field only
kneerose Oct 28, 2024
b40ab3f
chore: update test ids of metadata download and url of govAction deta…
kneerose Oct 28, 2024
e9455c3
test: vote context metadata anchor validation
kneerose Oct 28, 2024
71595c1
chore: use metadata url input testId instead of getByPlaceholder
kneerose Oct 28, 2024
c2bb584
Merge pull request #2238 from IntersectMBO/fix/anchor-validation
kneerose Oct 28, 2024
8827fe4
Merge pull request #2234 from IntersectMBO/fix/2233-ga-showing-empty-…
MSzalowski Oct 28, 2024
597876d
Merge pull request #2239 from IntersectMBO/tests/vote-context-anchor-…
kneerose Oct 28, 2024
0582ee4
fix: searching for metadatas in proposal list
MSzalowski Oct 24, 2024
9e9e9a7
fix: searching for metadatas in drep list
MSzalowski Oct 24, 2024
69267e7
fix: hlint warning on using maybe
MSzalowski Oct 24, 2024
cfe4e91
Merge pull request #2216 from IntersectMBO/fix/1893-drep-search-only-…
MSzalowski Oct 28, 2024
2eeac4a
Update govtool/frontend/src/i18n/locales/en.ts
MSzalowski Oct 28, 2024
a5e7dbd
Merge pull request #2202 from IntersectMBO/drep-search-copy
MSzalowski Oct 28, 2024
f0e58a8
chore: update dRep form references url and link error testId
kneerose Oct 28, 2024
9867c30
fix: drep list sql
MSzalowski Oct 28, 2024
5d33b50
Merge pull request #2241 from IntersectMBO/fix/fix-drep-list-sql
MSzalowski Oct 28, 2024
a9764b9
Merge pull request #2240 from IntersectMBO/chore/update-dRep-form-ref…
kneerose Oct 28, 2024
391ae0c
fix(#2247): fix counting the CC votes on governance actions
MSzalowski Oct 28, 2024
68ba0e2
Merge pull request #2248 from IntersectMBO/fix/2247-cc-votes-are-wron…
MSzalowski Oct 28, 2024
4a414c7
chore: bump GovTool to v1.0.23
MSzalowski Oct 28, 2024
59ed1f2
Merge pull request #2249 from IntersectMBO/chore/bump-govtool-to-v1.0.23
MSzalowski Oct 28, 2024
91758bd
Merge pull request #2250 from IntersectMBO/develop
MSzalowski Oct 28, 2024
4deaaf2
Merge pull request #2251 from IntersectMBO/test
MSzalowski Oct 29, 2024
69ebd77
chore: update GovTool-v1.0.23 release date
MSzalowski Oct 29, 2024
ec9cb2e
Merge pull request #2265 from IntersectMBO/chore/update-GovTool-v1.0.…
MSzalowski Oct 29, 2024
de6dec2
Merge pull request #2266 from IntersectMBO/develop
MSzalowski Oct 29, 2024
a0fadf9
fix: handle no results on get votes query
MSzalowski Oct 29, 2024
6f7e5fc
Merge pull request #2268 from IntersectMBO/fix/handle-no-results-in-g…
MSzalowski Oct 29, 2024
0153562
Merge pull request #2269 from IntersectMBO/develop
MSzalowski Oct 29, 2024
5f5fb5a
Merge pull request #2267 from IntersectMBO/test
MSzalowski Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ changes.

-

## [v1.0.23](https://github.com/IntersectMBO/govtool/releases/tag/v1.0.23) 2024-10-29

### Added

- Add searching for DRep and Proposal metadatas [Issue 1893](https://github.com/IntersectMBO/govtool/issues/1783)

### Fixed

- Fix validating metadata against the CIP standard [Issue 2233](https://github.com/IntersectMBO/govtool/issues/2233)
- Fix counting the CC votes [Issue 2247](https://github.com/IntersectMBO/govtool/issues/2247)

### Changed

-

### Removed

-

## [v1.0.22](https://github.com/IntersectMBO/govtool/releases/tag/v1.0.22) 2024-10-24

### Added
Expand All @@ -43,6 +62,7 @@ changes.
### Changed

- Bump to use Cardano Node `10.0.0-pre`
- Changed copy for no DRep found via search

### Removed

Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG
WORKDIR /src
COPY . .
RUN cabal build
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.22/x/vva-be/build/vva-be/vva-be /usr/local/bin
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.23/x/vva-be/build/vva-be/vva-be /usr/local/bin
2 changes: 1 addition & 1 deletion govtool/backend/Dockerfile.qovery
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG
WORKDIR /src
COPY . .
RUN cabal build
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.22/x/vva-be/build/vva-be/vva-be /usr/local/bin
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.23/x/vva-be/build/vva-be/vva-be /usr/local/bin

# Expose the necessary port
EXPOSE 9876
Expand Down
6 changes: 6 additions & 0 deletions govtool/backend/sql/list-dreps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ FROM
AND dr_first_register.rn = 1
LEFT JOIN tx AS tx_first_register ON tx_first_register.id = dr_first_register.tx_id
LEFT JOIN block AS block_first_register ON block_first_register.id = tx_first_register.block_id
WHERE
(
COALESCE(?, '') = '' OR
dh.view ILIKE ? OR
off_chain_vote_drep_data.given_name ILIKE ?
)
GROUP BY
dh.raw,
second_to_newest_drep_registration.voting_anchor_id,
Expand Down
20 changes: 15 additions & 5 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,30 @@ FROM
SUM(CASE WHEN vote = 'No' THEN 1 ELSE 0 END) AS ccNoVotes,
SUM(CASE WHEN vote = 'Abstain' THEN 1 ELSE 0 END) AS ccAbstainVotes
FROM
voting_procedure
voting_procedure AS vp
WHERE
committee_voter IS NOT NULL
vp.committee_voter IS NOT NULL
AND (vp.tx_id, vp.committee_voter, vp.gov_action_proposal_id) IN (
SELECT MAX(tx_id), committee_voter, gov_action_proposal_id
FROM voting_procedure
WHERE committee_voter IS NOT NULL
GROUP BY committee_voter, gov_action_proposal_id
)
GROUP BY
gov_action_proposal_id
) vp_by_cc
ON gov_action_proposal.id = vp_by_cc.gov_action_proposal_id

LEFT JOIN LatestDrepDistr ldd_cc ON ldd_cc.hash_id = voting_procedure.committee_voter
AND ldd_cc.rn = 1
LEFT JOIN gov_action_proposal AS prev_gov_action ON gov_action_proposal.prev_gov_action_proposal = prev_gov_action.id
LEFT JOIN tx AS prev_gov_action_tx ON prev_gov_action.tx_id = prev_gov_action_tx.id
WHERE (NOT ?
OR (concat(encode(creator_tx.hash, 'hex'), '#', gov_action_proposal.index) IN ?))
WHERE
(COALESCE(?, '') = '' OR
off_chain_vote_gov_action_data.title ILIKE ? OR
off_chain_vote_gov_action_data.abstract ILIKE ? OR
off_chain_vote_gov_action_data.motivation ILIKE ? OR
off_chain_vote_gov_action_data.rationale ILIKE ? OR
concat(encode(creator_tx.hash, 'hex'), '#', gov_action_proposal.index) ILIKE ?)
AND gov_action_proposal.expiration >(
SELECT
Max(NO)
Expand Down
28 changes: 14 additions & 14 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ 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
dreps <- cacheRequest dRepListCache () (DRep.listDReps mSearchQuery)

let filterDRepsByQuery = case mSearchQuery of
Nothing -> filter $ \Types.DRepRegistration {..} -> dRepRegistrationType == Types.DRep
Expand Down Expand Up @@ -357,20 +357,20 @@ listProposals selectedTypes sortMode mPage mPageSize mDrepRaw mSearchQuery = do
map (voteParamsProposalId . voteResponseVote)
<$> getVotes drepId [] Nothing Nothing


CacheEnv {proposalListCache} <- asks vvaCache
mappedAndSortedProposals <- do
proposals <- cacheRequest proposalListCache () Proposal.listProposals
mappedSortedAndFilteredProposals <- mapSortAndFilterProposals selectedTypes sortMode proposals
return $ filter
( \p@ProposalResponse {proposalResponseId} ->
proposalResponseId `notElem` proposalsToRemove
&& isProposalSearchedFor mSearchQuery p
) mappedSortedAndFilteredProposals

let total = length mappedAndSortedProposals :: Int

let elements = take pageSize $ drop (page * pageSize) mappedAndSortedProposals

proposals <- cacheRequest proposalListCache () (Proposal.listProposals mSearchQuery)

mappedSortedAndFilteredProposals <- mapSortAndFilterProposals selectedTypes sortMode proposals
let filteredProposals = filter
( \p@ProposalResponse {proposalResponseId} ->
proposalResponseId `notElem` proposalsToRemove
&& isProposalSearchedFor mSearchQuery p
) mappedSortedAndFilteredProposals

let total = length filteredProposals :: Int

let elements = take pageSize $ drop (page * pageSize) filteredProposals

return $ ListProposalsResponse
{ listProposalsResponsePage = fromIntegral page
Expand Down
3 changes: 0 additions & 3 deletions govtool/backend/src/VVA/AdaHolder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ import VVA.Types
sqlFrom :: ByteString -> SQL.Query
sqlFrom bs = fromString $ unpack $ Text.decodeUtf8 bs

listDRepsSql :: SQL.Query
listDRepsSql = sqlFrom $(embedFile "sql/list-dreps.sql")

getCurrentDelegationSql :: SQL.Query
getCurrentDelegationSql = sqlFrom $(embedFile "sql/get-current-delegation.sql")

Expand Down
68 changes: 38 additions & 30 deletions govtool/backend/src/VVA/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import qualified Data.Text.Encoding as Text
import Data.Time

import qualified Database.PostgreSQL.Simple as SQL

import VVA.Config
import VVA.Pool (ConnectionPool, withPool)
import qualified VVA.Proposal as Proposal
Expand All @@ -36,29 +35,19 @@ import VVA.Types (AppError, DRepInfo (..), DRepRegist
sqlFrom :: ByteString -> SQL.Query
sqlFrom bs = fromString $ unpack $ Text.decodeUtf8 bs

getVotingPowerSql :: SQL.Query
getVotingPowerSql = sqlFrom $(embedFile "sql/get-voting-power.sql")

getVotingPower ::
(Has ConnectionPool r, Has VVAConfig r, MonadReader r m, MonadIO m, MonadFail m) =>
Text ->
m Integer
getVotingPower drepId = withPool $ \conn -> do
result <-
liftIO
(SQL.query @_ @(SQL.Only Scientific) conn getVotingPowerSql $ SQL.Only drepId)
case result of
[SQL.Only votingPower] -> return $ floor votingPower
[] -> return 0

listDRepsSql :: SQL.Query
listDRepsSql = sqlFrom $(embedFile "sql/list-dreps.sql")

listDReps ::
(Has ConnectionPool r, Has VVAConfig r, MonadReader r m, MonadIO m) =>
m [DRepRegistration]
listDReps = withPool $ \conn -> do
results <- liftIO $ SQL.query_ conn listDRepsSql
Maybe Text -> m [DRepRegistration]
listDReps mSearchQuery = withPool $ \conn -> do
let searchParam = fromMaybe "" mSearchQuery
results <- liftIO $ SQL.query conn listDRepsSql
( searchParam
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
)
timeZone <- liftIO getCurrentTimeZone
return
[ DRepRegistration drepHash drepView isScriptBased url dataHash (floor @Scientific deposit) votingPower status drepType txHash (localTimeToUTC timeZone date) metadataError paymentAddress givenName objectives motivations qualifications imageUrl imageHash
Expand Down Expand Up @@ -95,6 +84,19 @@ listDReps = withPool $ \conn -> do
| Data.Maybe.isJust url = DRep
]

getVotingPowerSql :: SQL.Query
getVotingPowerSql = sqlFrom $(embedFile "sql/get-voting-power.sql")

getVotingPower ::
(Has ConnectionPool r, Has VVAConfig r, MonadReader r m, MonadIO m, MonadFail m) =>
Text ->
m Integer
getVotingPower drepId = withPool $ \conn -> do
result <- liftIO (SQL.query @_ @(SQL.Only Scientific) conn getVotingPowerSql $ SQL.Only drepId)
case result of
[SQL.Only votingPower] -> return $ floor votingPower
[] -> return 0

getVotesSql :: SQL.Query
getVotesSql = sqlFrom $(embedFile "sql/get-votes.sql")

Expand All @@ -105,17 +107,23 @@ getVotes ::
m ([Vote], [Proposal])
getVotes drepId selectedProposals = withPool $ \conn -> do
results <- liftIO $ SQL.query conn getVotesSql (SQL.Only drepId)
let proposalsToSelect = if null selectedProposals
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' epochNo' (localTimeToUTC timeZone date') voteTxHash'
| (proposalId', govActionId', drepId', vote', url', docHash', epochNo', date', voteTxHash') <- results
, govActionId' `elem` proposalsToSelect
], proposals)

if null results
then return ([], [])
else do
let proposalsToSelect = if null selectedProposals
then [ govActionId | (_, govActionId, _, _, _, _, _, _, _) <- results]
else selectedProposals
proposals <- if null proposalsToSelect
then return []
else Proposal.getProposals (Just proposalsToSelect)
let proposalMap = M.fromList $ map (\x -> (proposalId x, x)) proposals
timeZone <- liftIO getCurrentTimeZone
let votes = [ Vote proposalId' drepId' vote' url' docHash' epochNo' (localTimeToUTC timeZone date') voteTxHash'
| (proposalId', govActionId', drepId', vote', url', docHash', epochNo', date', voteTxHash') <- results
, govActionId' `elem` proposalsToSelect
]
return (votes, proposals)

getDRepInfoSql :: SQL.Query
getDRepInfoSql = sqlFrom $(embedFile "sql/get-drep-info.sql")
Expand Down
40 changes: 25 additions & 15 deletions govtool/backend/src/VVA/Proposal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ import qualified Data.Text.IO as Text
import Data.Time

import qualified Database.PostgreSQL.Simple as SQL

import qualified GHC.Generics as SQL

import Text.Read (readMaybe)
import qualified Database.PostgreSQL.Simple.Types as PG
import Database.PostgreSQL.Simple.ToField (ToField(..))
import Database.PostgreSQL.Simple.ToRow (ToRow(..))

import VVA.Config
import VVA.Pool (ConnectionPool, withPool)
Expand All @@ -43,28 +42,39 @@ sqlFrom bs = fromString $ unpack $ Text.decodeUtf8 bs
listProposalsSql :: SQL.Query
listProposalsSql = sqlFrom $(embedFile "sql/list-proposals.sql")

newtype TextArray = TextArray [Text]

instance ToRow TextArray where
toRow (TextArray texts) = map toField texts

listProposals ::
(Has ConnectionPool r, Has VVAConfig r, MonadReader r m, MonadIO m, MonadFail m, MonadError AppError m) =>
m [Proposal]
listProposals = getProposals Nothing
Maybe Text -> m [Proposal]
listProposals mSearch = getProposals (fmap (:[]) mSearch)

getProposal ::
(Has ConnectionPool r, Has VVAConfig r, MonadReader r m, MonadIO m, MonadFail m, MonadError AppError m) =>
Text ->
Integer ->
m Proposal
getProposal txHash index = do
result <- getProposals (Just [txHash <> "#" <> pack (show index)])
let proposalId = txHash <> "#" <> pack (show index)
result <- getProposals (Just [proposalId])
case result of
[] -> throwError $ NotFoundError ("Proposal with id: " <> txHash <> "#" <> pack (show index) <> " not found")
[] -> throwError $ NotFoundError ("Proposal with id: " <> proposalId <> " not found")
[a] -> return a
_ -> throwError $ CriticalError ("Multiple proposal found for id: " <> txHash <> "#" <> pack (show index) <> ". This should never happen")
_ -> throwError $ CriticalError ("Multiple proposals found for id: " <> proposalId <> ". This should never happen")

getProposals ::
(Has ConnectionPool r, Has VVAConfig r, MonadReader r m, MonadIO m, MonadFail m, MonadError AppError m) =>
Maybe [Text] ->
m [Proposal]
getProposals mProposalIds = withPool $ \conn ->
liftIO $ case mProposalIds of
Nothing -> SQL.query @(Bool, SQL.In [Text]) conn listProposalsSql (False, SQL.In [])
Just proposalIds -> SQL.query conn listProposalsSql (True, SQL.In proposalIds)
Maybe [Text] -> m [Proposal]
getProposals mSearchTerms = withPool $ \conn -> do
let searchParam = maybe "" head mSearchTerms
liftIO $ SQL.query conn listProposalsSql
( searchParam
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
)
2 changes: 1 addition & 1 deletion govtool/backend/vva-be.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.6
name: vva-be
version: 1.0.22
version: 1.0.23

-- A short (one-line) description of the package.
-- synopsis:
Expand Down
4 changes: 2 additions & 2 deletions govtool/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions govtool/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@govtool/frontend",
"private": true,
"version": "1.0.22",
"version": "1.0.23",
"type": "module",
"scripts": {
"build": "vite build",
Expand Down Expand Up @@ -109,5 +109,5 @@
"typescript": "^5.0.2"
},
"readme": "ERROR: No README data found!",
"_id": "govtool@1.0.22"
"_id": "govtool@1.0.23"
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
title={title}
isDataMissing={metadataStatus}
/>
<GovernanceActionCardElement
label={t("govActions.abstract")}
text={abstract}
textVariant="twoLines"
dataTestId="governance-action-abstract"
isSliderCard
isMarkdown
/>
{!metadataStatus && (
<GovernanceActionCardElement
label={t("govActions.abstract")}
text={abstract}
textVariant="twoLines"
dataTestId="governance-action-abstract"
isSliderCard
isMarkdown
/>
)}
<GovernanceActionCardElement
label={t("govActions.governanceActionType")}
text={getProposalTypeLabel(type)}
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export const en = {
"Select this to signal no confidence in the current constitutional committee by voting NO on every proposal and voting YES to no confidence proposals",
noConfidenceDefaultTitle: "Signal No Confidence on Every Vote",
noResultsForTheSearchTitle: "No DReps found",
noResultsForTheSearchDescription: "Please try a different search",
noResultsForTheSearchDescription: "If you can't find the DRep you're looking for, either they are not registered, requested not to be listed in the DRep Directory, or did not submit correct metadata during registration.",
title: "DRep Directory",
votingPower: "Voting Power",
},
Expand Down
Loading
Loading