Skip to content

Commit

Permalink
Update VotingPeriod API model
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed May 30, 2024
1 parent 0da73c9 commit 338a111
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Tzkt.Api/Models/Voting/VotingPeriod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public class VotingPeriod
/// <summary>
/// The number of bakers on the voters list
/// </summary>
public int? TotalBakers { get; set; }
public int TotalBakers { get; set; }

/// <summary>
/// Total voting power of bakers on the voters list
/// </summary>
public long? TotalVotingPower { get; set; }
public long TotalVotingPower { get; set; }

#region proposal
/// <summary>
Expand Down Expand Up @@ -140,7 +140,7 @@ public class VotingPeriod
/// <summary>
/// [DEPRECATED]
/// </summary>
public int? TotalRolls => TotalVotingPower == null ? null : (int)(TotalVotingPower / 6_000_000_000);
public int TotalRolls => (int)(TotalVotingPower / 6_000_000_000);

/// <summary>
/// [DEPRECATED]
Expand Down
4 changes: 2 additions & 2 deletions Tzkt.Api/Services/Home/HomeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ async Task<GovernanceData> GetGovernanceData()
Hash = x.Hash,
Extras = x.Extras,
VotingPower = x.VotingPower,
VotingPowerPercentage = Math.Round(100.0 * x.VotingPower / (long)period.TotalVotingPower!, 2)
VotingPowerPercentage = Math.Round(100.0 * x.VotingPower / period.TotalVotingPower, 2)
}).ToList(),
UpvotesQuorum = period.UpvotesQuorum,
PeriodEndTime = period.EndTime,
Expand Down Expand Up @@ -622,7 +622,7 @@ async Task<GovernanceData> GetGovernanceData()
: 0;

result.Participation = period.TotalVotingPower > 0
? Math.Round(100.0 * totalVoted / (long)period.TotalVotingPower, 2)
? Math.Round(100.0 * totalVoted / period.TotalVotingPower, 2)
: 0;

result.BallotsQuorum = Math.Round((double)period.BallotsQuorum!, 2);
Expand Down

0 comments on commit 338a111

Please sign in to comment.