diff --git a/actix_mvc_app/src/controllers/governance.rs b/actix_mvc_app/src/controllers/governance.rs index 073b8e1..04d4b89 100644 --- a/actix_mvc_app/src/controllers/governance.rs +++ b/actix_mvc_app/src/controllers/governance.rs @@ -112,7 +112,12 @@ impl GovernanceController { // Get the nearest deadline proposal for the voting pane if let Some(nearest_proposal) = sorted_active_proposals.first() { + // Calculate voting results for the nearest proposal + let results = Self::calculate_voting_results_from_proposal(nearest_proposal); + + // Add both the proposal and its results to the context ctx.insert("nearest_proposal", nearest_proposal); + ctx.insert("nearest_proposal_results", &results); } // Calculate statistics from the database diff --git a/actix_mvc_app/src/views/governance/index.html b/actix_mvc_app/src/views/governance/index.html index 6765880..ec7351e 100644 --- a/actix_mvc_app/src/views/governance/index.html +++ b/actix_mvc_app/src/views/governance/index.html @@ -63,16 +63,40 @@

{{ nearest_proposal.description }}

+ {% set yes_percent = 0 %} + {% set no_percent = 0 %} + {% set abstain_percent = 0 %} + {% set total_votes = 0 %} + + {% if nearest_proposal_results is defined %} + {% if nearest_proposal_results.total_votes > 0 %} + {% set yes_percent = (nearest_proposal_results.yes_count * 100 / nearest_proposal_results.total_votes) | + int %} + {% set no_percent = (nearest_proposal_results.no_count * 100 / nearest_proposal_results.total_votes) | + int %} + {% set abstain_percent = (nearest_proposal_results.abstain_count * 100 / + nearest_proposal_results.total_votes) | + int %} + {% endif %} + {% set total_votes = nearest_proposal_results.total_votes %} + {% endif %} +
-
65% Yes
-
35% No
+
{{ yes_percent }}% Yes +
+
{{ no_percent }}% No +
+
{{ abstain_percent + }}% Abstain +
- 26 votes cast - Quorum: 75% reached + {{ total_votes }} votes cast + Quorum: {% if total_votes >= 20 %}75% reached{% else %}Not reached{% endif %}