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

Fixes and Additions: Dockerfile Correction, Optional Search Query Parameter #574

Merged
merged 34 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7f9e84c
[#536] add BE search for governance actions
j-dyczka Mar 26, 2024
8380cb6
[#536] make filtering and sorting actions reusable
j-dyczka Mar 26, 2024
77b297a
Vote Context
JanJaroszczak Mar 26, 2024
b4fe47a
[#569] Fix Dockerfile to correctly build backend module
placek Mar 27, 2024
5c820c0
[#541] move individual dashboard cards into separate components
j-dyczka Mar 20, 2024
3ba91d2
[#541] refactor dashboard cards
j-dyczka Mar 20, 2024
66d36fb
[#257 #374] Display GA using data from BE
JanJaroszczak Mar 27, 2024
09cf65e
[#566] add optional 'search' query param
jankun4 Mar 26, 2024
e536871
Update vva-be.cabal
jankun4 Mar 27, 2024
f7bd059
Merge pull request #570 from IntersectMBO/fix/569-deployment-issue-du…
placek Mar 27, 2024
d1bbce2
Merge pull request #572 from IntersectMBO/jankun4-patch-2
placek Mar 27, 2024
fa89b5f
Merge pull request #568 from IntersectMBO/vote-context
JanJaroszczak Mar 27, 2024
c4c7bd9
Merge pull request #562 from IntersectMBO/dashboard-cards-refactor
jdyczka Mar 27, 2024
315731e
[#257 #374] Fixes
JanJaroszczak Mar 27, 2024
43ff59c
Merge pull request #571 from IntersectMBO/257-374-display-ga-data-fro…
JanJaroszczak Mar 27, 2024
8069691
Update Cardano DB Sync version to the newest release
placek Mar 27, 2024
2767c07
[#555] Fix missing environment variable for domain in resync workflow
placek Mar 27, 2024
31d4318
[#555] Update Cardano Node to version 8.9.0
placek Mar 27, 2024
4eec162
Merge pull request #576 from IntersectMBO/chore/555-update-cardano-db…
placek Mar 27, 2024
ebe8f41
Merge pull request #565 from IntersectMBO/feat/536-ga-search
jdyczka Mar 27, 2024
9355c4e
[#530] Fix broken Haskell backend developers' configuration
placek Mar 25, 2024
cc13ffe
[#530] Make the direnv nix-shell helpers more reliable and responsive
placek Mar 25, 2024
c7c34e0
[#530] Add stylish-haskell to the developer's toolset
placek Mar 25, 2024
91f91c3
[#530] Add hlint to the developer's toolset
placek Mar 25, 2024
ef0e93b
[#530] Add stylish-haskell configuration
placek Mar 25, 2024
9570171
[#530] Update shell information to connect with readme files
placek Mar 25, 2024
8ca4c8f
[#530] Apply contribution tools documentation on backend module
placek Mar 25, 2024
a68773f
[#530] Move flake configuration to flake parts
placek Mar 28, 2024
e7dbb19
[#530] Install pre-commit tool with basic configuration
placek Mar 28, 2024
63f038c
Trim whitespaces and ensure there is no new line
placek Mar 28, 2024
b769363
[#530] Add hlint and stylish-haskell to pre-commit configuration
placek Mar 28, 2024
014f167
[#530] Apply the hlint and stylish-haskell hints
placek Mar 28, 2024
0a28336
[#530] Add GitHub workflow for backend lint and formatting checks
placek Mar 28, 2024
65fd617
Merge pull request #542 from IntersectMBO/chore/530-implement-code-fo…
placek Mar 28, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ changes.

### Fixed

- 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)
- Fix make button disble when wallet tries connect [Issue 265](https://github.com/IntersectMBO/govtool/issues/265)
Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM 733019650473.dkr.ecr.eu-west-1.amazonaws.com/backend-base:$BASE_IMAGE_TAG
WORKDIR /src
COPY . .
RUN cabal build
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.8/vva-be-0.1.0.0/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-0.1.0.0/x/vva-be/build/vva-be/vva-be /usr/local/bin
2 changes: 2 additions & 0 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ SELECT
off_chain_vote_data.abstract,
off_chain_vote_data.motivation,
off_chain_vote_data.rationale,
off_chain_vote_data.json,
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 Expand Up @@ -109,6 +110,7 @@ GROUP BY
off_chain_vote_data.abstract,
off_chain_vote_data.motivation,
off_chain_vote_data.rationale,
off_chain_vote_data.json,
gov_action_proposal.index,
creator_tx.hash,
creator_block.time,
Expand Down
25 changes: 23 additions & 2 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type VVAApi =
:> QueryParam "page" Natural
:> QueryParam "pageSize" Natural
:> QueryParam "drepId" HexText
:> QueryParam "search" Text
:> Get '[JSON] ListProposalsResponse
:<|> "proposal" :> "get" :> Capture "proposalId" GovActionId :> QueryParam "drepId" HexText :> Get '[JSON] GetProposalResponse
:<|> "epoch" :> "params" :> Get '[JSON] GetCurrentEpochParamsResponse
Expand Down Expand Up @@ -127,6 +128,7 @@ proposalToResponse Types.Proposal {..} =
proposalResponseAbout = proposalAbout,
proposalResponseMotivation = proposalMotivaiton,
proposalResponseRationale = proposalRationale,
proposalResponseMetadata = GovernanceActionMetadata <$> proposalMetadata,
proposalResponseYesVotes = proposalYesVotes,
proposalResponseNoVotes = proposalNoVotes,
proposalResponseAbstainVotes = proposalAbstainVotes
Expand Down Expand Up @@ -217,8 +219,9 @@ listProposals
-> Maybe Natural
-> Maybe Natural
-> Maybe HexText
-> Maybe Text
-> m ListProposalsResponse
listProposals selectedTypes sortMode mPage mPageSize mDrepRaw = do
listProposals selectedTypes sortMode mPage mPageSize mDrepRaw mSearchQuery = do
let page = (fromIntegral $ fromMaybe 0 mPage) :: Int
pageSize = (fromIntegral $ fromMaybe 10 mPageSize) :: Int

Expand All @@ -229,11 +232,29 @@ listProposals selectedTypes sortMode mPage mPageSize mDrepRaw = do
map (voteParamsProposalId . voteResponseVote)
<$> getVotes drepId [] Nothing



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

let result = searchQuery `isInfixOf` title
|| searchQuery `isInfixOf` about
|| searchQuery `isInfixOf` motivation
|| searchQuery `isInfixOf` rationale

pure result

CacheEnv {proposalListCache} <- asks vvaCache
mappedAndSortedProposals <-
filter
( \ProposalResponse {proposalResponseId} ->
( \p@ProposalResponse {proposalResponseId} ->
proposalResponseId `notElem` proposalsToRemove
&& filterF p
)
<$>
mapSortAndFilterProposals selectedTypes sortMode
Expand Down
23 changes: 23 additions & 0 deletions govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,27 @@ instance ToSchema GovernanceActionDetails where
?~ toJSON
("{\"some_key\": \"some value\", \"some_key2\": [1,2,3]}" :: Text)


newtype GovernanceActionMetadata = GovernanceActionMetadata Value
deriving newtype (Show)

instance FromJSON GovernanceActionMetadata where
parseJSON v@(Aeson.Object o) = pure (GovernanceActionMetadata v)
parseJSON _ = fail "GovernanceActionMetadata has to be an object"

instance ToJSON GovernanceActionMetadata where
toJSON (GovernanceActionMetadata g) = g

instance ToSchema GovernanceActionMetadata where
declareNamedSchema _ = pure $ NamedSchema (Just "GovernanceActionMetadata") $ mempty
& type_ ?~ OpenApiObject
& description ?~ "A Governance Action metadata"
& example
?~ toJSON
("{\"some_key\": \"some value\", \"some_key2\": [1,2,3]}" :: Text)



data ProposalResponse = ProposalResponse
{ proposalResponseId :: Text,
proposalResponseTxHash :: HexText,
Expand All @@ -249,6 +270,7 @@ data ProposalResponse = ProposalResponse
proposalResponseAbout :: Maybe Text,
proposalResponseMotivation :: Maybe Text,
proposalResponseRationale :: Maybe Text,
proposalResponseMetadata :: Maybe GovernanceActionMetadata,
proposalResponseYesVotes :: Integer,
proposalResponseNoVotes :: Integer,
proposalResponseAbstainVotes :: Integer
Expand All @@ -273,6 +295,7 @@ exampleProposalResponse = "{ \"id\": \"proposalId123\","
<> "\"about\": \"Proposal About\","
<> "\"motivation\": \"Proposal Motivation\","
<> "\"rationale\": \"Proposal Rationale\","
<> "\"metadata\": {\"key\": \"value\"},"
<> "\"yesVotes\": 0,"
<> "\"noVotes\": 0,"
<> "\"abstainVotes\": 0}"
Expand Down
2 changes: 2 additions & 0 deletions govtool/backend/src/VVA/Proposal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ getProposals mProposalIds = withPool $ \conn -> do
, about'
, motivation'
, rationale'
, metadataJson'
, yesVotes'
, noVotes'
, abstainVotes'
Expand All @@ -108,6 +109,7 @@ getProposals mProposalIds = withPool $ \conn -> do
about'
motivation'
rationale'
metadataJson'
(floor @Scientific yesVotes')
(floor @Scientific noVotes')
(floor @Scientific abstainVotes')
Expand Down
1 change: 1 addition & 0 deletions govtool/backend/src/VVA/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ data Proposal = Proposal
proposalAbout :: Maybe Text,
proposalMotivaiton :: Maybe Text,
proposalRationale :: Maybe Text,
proposalMetadata :: Maybe Value,
proposalYesVotes :: Integer,
proposalNoVotes :: Integer,
proposalAbstainVotes :: Integer
Expand Down
4 changes: 2 additions & 2 deletions govtool/backend/vva-be.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ executable vva-be
, lens
, cache
, clock
, resource-pool
, resource-pool == 0.2.3.2
, postgresql-simple
, data-has
, bytestring
Expand Down Expand Up @@ -113,4 +113,4 @@ library
, VVA.Cache
, VVA.Pool
, VVA.Types
, VVA.Network
, VVA.Network
29 changes: 25 additions & 4 deletions govtool/frontend/src/components/atoms/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,27 @@ import { TextAreaProps } from "./types";
const TextAreaBase = styled(TextareaAutosize)(
() => `
font-family: "Poppins";
font-size: 16px;
font-weight: 400;
::placeholder {
font-family: "Poppins";
font-size: 16px;
font-weight: 400;
color: #a6a6a6;
}
`,
);

export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
({ errorMessage, maxLength = 500, onBlur, onFocus, ...props }, ref) => {
(
{
errorMessage,
maxLength = 500,
onBlur,
onFocus,
isModifiedLayout,
...props
},
ref,
) => {
const { isMobile } = useScreenDimension();
const textAraeRef = useRef<HTMLTextAreaElement>(null);

Expand Down Expand Up @@ -51,19 +59,32 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
[handleBlur, handleFocus],
);

const getTexAreaHeight = () => {
if (isModifiedLayout && isMobile) return "312px";
if (isModifiedLayout) return "208px";
if (isMobile) return "104px";
return "128px";
};

return (
<TextAreaBase
style={{
border: `1px solid ${errorMessage ? "red" : "#6F99FF"}`,
backgroundColor: errorMessage ? "#FAEAEB" : "white",
borderRadius: "24px",
height: isMobile ? "104px" : "128px",
height: getTexAreaHeight(),
outline: "none",
padding: "12px 14px",
resize: "none",
}}
maxLength={maxLength}
ref={textAraeRef}
sx={{
fontSize: isModifiedLayout ? "12px" : "auto",
"&::placeholder": {
fontSize: isModifiedLayout ? "12px" : "16px",
},
}}
{...props}
/>
);
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/components/atoms/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type FormHelpfulTextProps = {

export type TextAreaProps = TextareaAutosizeProps & {
errorMessage?: string;
isModifiedLayout?: boolean;
};

export type InfoTextProps = {
Expand Down
10 changes: 9 additions & 1 deletion govtool/frontend/src/components/molecules/Field/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaFieldProps>(
} as unknown as HTMLTextAreaElement),
[handleBlur, handleFocus],
);

const getCounterBottomSxValue = () => {
if (props.isModifiedLayout && errorMessage) return 30;
if (props.isModifiedLayout) return 10;
if (errorMessage) return 52.5;
return 35;
};

return (
<Box
sx={{
Expand Down Expand Up @@ -92,7 +100,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaFieldProps>(
<Typography
color="#8E908E"
sx={{
bottom: errorMessage ? 52.5 : 35,
bottom: getCounterBottomSxValue(),
position: "absolute",
right: 15,
}}
Expand Down
Loading
Loading