Skip to content

Commit

Permalink
chore: remove references from proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Jul 31, 2024
1 parent cf57b40 commit 8210586
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion govtool/backend/example-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"host" : "localhost",
"dbname" : "cexplorer",
"user" : "postgres",
"password" : "v8hlDV0yMAHHlIurYupj",
"password" : "postgres",
"port" : 5432
},
"port" : 9999,
Expand Down
2 changes: 0 additions & 2 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ SELECT
off_chain_vote_gov_action_data.abstract,
off_chain_vote_gov_action_data.motivation,
off_chain_vote_gov_action_data.rationale,
off_chain_vote_data.json,
off_chain_vote_data.json#>'{body, references}' as references,
coalesce(Sum(ldd.amount) FILTER (WHERE voting_procedure.vote::text = 'Yes'), 0) +(
CASE WHEN gov_action_proposal.type = 'NoConfidence' THEN
always_no_confidence_voting_power.amount
Expand Down
13 changes: 4 additions & 9 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ import Control.Exception (throw, throwIO)
import Control.Monad.Except (runExceptT, throwError)
import Control.Monad.Reader

import Data.Aeson (Result (Error, Success), fromJSON, Value)
import Data.Aeson (Value(..), Array, decode, encode, FromJSON, ToJSON)
import Data.Bool (Bool)
import Data.List (sortOn)
import qualified Data.Map as Map
import Data.Maybe (Maybe (Nothing), catMaybes, fromMaybe)
import Data.Maybe (Maybe (Nothing), catMaybes, fromMaybe, mapMaybe)
import Data.Ord (Down (..))
import Data.Text hiding (any, drop, elem, filter, length, map, null, take)
import qualified Data.Text as Text
import qualified Data.Vector as V


import Numeric.Natural (Natural)

Expand Down Expand Up @@ -177,12 +179,6 @@ getVotingPower (unHexText -> dRepId) = do
CacheEnv {dRepVotingPowerCache} <- asks vvaCache
cacheRequest dRepVotingPowerCache dRepId $ DRep.getVotingPower dRepId

decodeReferences :: Maybe Value -> Maybe [Text]
decodeReferences Nothing = Nothing
decodeReferences (Just val) = case fromJSON val of
Success texts -> Just texts
Error _ -> Nothing

proposalToResponse :: Types.Proposal -> ProposalResponse
proposalToResponse Types.Proposal {..} =
ProposalResponse
Expand All @@ -201,7 +197,6 @@ proposalToResponse Types.Proposal {..} =
proposalResponseAbstract = proposalAbstract,
proposalResponseMotivation = proposalMotivation,
proposalResponseRationale = proposalRationale,
proposalResponseReferences = fromMaybe [] (decodeReferences proposalReferences),
proposalResponseYesVotes = proposalYesVotes,
proposalResponseNoVotes = proposalNoVotes,
proposalResponseAbstainVotes = proposalAbstainVotes
Expand Down
2 changes: 0 additions & 2 deletions govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ data ProposalResponse
, proposalResponseAbstract :: Maybe Text
, proposalResponseMotivation :: Maybe Text
, proposalResponseRationale :: Maybe Text
, proposalResponseReferences :: [Text]
, proposalResponseYesVotes :: Integer
, proposalResponseNoVotes :: Integer
, proposalResponseAbstainVotes :: Integer
Expand All @@ -479,7 +478,6 @@ exampleProposalResponse = "{ \"id\": \"proposalId123\","
<> "\"abstract\": \"Proposal About\","
<> "\"motivation\": \"Proposal Motivation\","
<> "\"rationale\": \"Proposal Rationale\","
<> "\"references\": [\"google.com\"],"
<> "\"yesVotes\": 0,"
<> "\"noVotes\": 0,"
<> "\"abstainVotes\": 0}"
Expand Down
2 changes: 0 additions & 2 deletions govtool/backend/src/VVA/Proposal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ getProposals mProposalIds = withPool $ \conn -> do
, about'
, motivation'
, rationale'
, references'
, yesVotes'
, noVotes'
, abstainVotes'
Expand All @@ -110,7 +109,6 @@ getProposals mProposalIds = withPool $ \conn -> do
about'
motivation'
rationale'
references'
(floor @Scientific yesVotes')
(floor @Scientific noVotes')
(floor @Scientific abstainVotes')
Expand Down
1 change: 0 additions & 1 deletion govtool/backend/src/VVA/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ data Proposal
, proposalAbstract :: Maybe Text
, proposalMotivation :: Maybe Text
, proposalRationale :: Maybe Text
, proposalReferences :: Maybe Value
, proposalYesVotes :: Integer
, proposalNoVotes :: Integer
, proposalAbstainVotes :: Integer
Expand Down

0 comments on commit 8210586

Please sign in to comment.