Skip to content

Commit

Permalink
feat(#1644): provide network name to network metrics endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Jul 31, 2024
1 parent 6d3b148 commit bbb3ef9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ changes.

### Added

-
- Add network name to GET /network/metrics [Issue 1644](https://github.com/IntersectMBO/govtool/issues/1644)

### Fixed

Expand Down
4 changes: 3 additions & 1 deletion govtool/backend/sql/get-network-metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ SELECT
total_drep_votes.count,
total_registered_dreps.count,
always_abstain_voting_power.amount,
always_no_confidence_voting_power.amount
always_no_confidence_voting_power.amount,
network_name
FROM
current_epoch
CROSS JOIN current_block
Expand All @@ -82,3 +83,4 @@ FROM
CROSS JOIN total_registered_dreps
CROSS JOIN always_abstain_voting_power
CROSS JOIN always_no_confidence_voting_power
CROSS JOIN meta;
1 change: 1 addition & 0 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ getNetworkMetrics = do
, getNetworkMetricsResponseTotalRegisteredDReps = networkMetricsTotalRegisteredDReps
, getNetworkMetricsResponseAlwaysAbstainVotingPower = networkMetricsAlwaysAbstainVotingPower
, getNetworkMetricsResponseAlwaysNoConfidenceVotingPower = networkMetricsAlwaysNoConfidenceVotingPower
, getNetworkMetricsResponseNetworkName = networkMetricsNetworkName
}

validateProposalMetadata :: App m => MetadataValidationParams -> m (Types.MetadataValidationResult Types.ProposalMetadata)
Expand Down
4 changes: 3 additions & 1 deletion govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ data GetNetworkMetricsResponse
, getNetworkMetricsResponseTotalRegisteredDReps :: Integer
, getNetworkMetricsResponseAlwaysAbstainVotingPower :: Integer
, getNetworkMetricsResponseAlwaysNoConfidenceVotingPower :: Integer
, getNetworkMetricsResponseNetworkName :: Text
}

deriveJSON (jsonOptions "getNetworkMetricsResponse") ''GetNetworkMetricsResponse
Expand All @@ -959,7 +960,8 @@ exampleGetNetworkMetricsResponse =
<> "\"totalDRepVotes\": 0,"
<> "\"totalRegisteredDReps\": 0,"
<> "\"alwaysAbstainVotingPower\": 0,"
<> "\"alwaysNoConfidenceVotingPower\": 0}"
<> "\"alwaysNoConfidenceVotingPower\": 0,"
<> "\"networkName\": \"Mainnet\"}"

instance ToSchema GetNetworkMetricsResponse where
declareNamedSchema _ = pure $ NamedSchema (Just "GetNetworkMetricsResponse") $ mempty
Expand Down
2 changes: 2 additions & 0 deletions govtool/backend/src/VVA/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ networkMetrics = withPool $ \conn -> do
, total_registered_dreps
, always_abstain_voting_power
, always_no_confidence_voting_power
, network_name
)] -> return $ NetworkMetrics
current_time
epoch_no
Expand All @@ -55,4 +56,5 @@ networkMetrics = withPool $ \conn -> do
total_registered_dreps
always_abstain_voting_power
always_no_confidence_voting_power
network_name
_ -> throwError $ CriticalError "Could not query the network metrics. This should never happen."
1 change: 1 addition & 0 deletions govtool/backend/src/VVA/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ data NetworkMetrics
, networkMetricsTotalRegisteredDReps :: Integer
, networkMetricsAlwaysAbstainVotingPower :: Integer
, networkMetricsAlwaysNoConfidenceVotingPower :: Integer
, networkMetricsNetworkName :: Text
}

data Delegation
Expand Down

0 comments on commit bbb3ef9

Please sign in to comment.