Fix initial load
This commit is contained in:
parent
97d0ae2170
commit
6356ddc7c6
@ -26,11 +26,11 @@ namespace Result.Data
|
||||
var results = connection.Query("SELECT vote, COUNT(id) AS count FROM votes GROUP BY vote ORDER BY vote");
|
||||
if (results.Any(x => x.vote == "a"))
|
||||
{
|
||||
model.OptionA = results.First(x => x.vote == "a").count;
|
||||
model.OptionA = (int) results.First(x => x.vote == "a").count;
|
||||
}
|
||||
if (results.Any(x => x.vote == "b"))
|
||||
{
|
||||
model.OptionB = results.First(x => x.vote == "b").count;
|
||||
model.OptionB = (int) results.First(x => x.vote == "b").count;
|
||||
}
|
||||
model.VoteCount = model.OptionA + model.OptionB;
|
||||
}
|
||||
|
@ -26,12 +26,12 @@
|
||||
<div id="choice">
|
||||
<div class="choice resulta">
|
||||
<div class="label">@Model.OptionA</div>
|
||||
<div class="stat" id="optionA"></div>
|
||||
<div class="stat" id="optionA">50%</div>
|
||||
</div>
|
||||
<div class="divider"></div>
|
||||
<div class="choice resultb">
|
||||
<div class="label">@Model.OptionB</div>
|
||||
<div class="stat" id="optionB"></div>
|
||||
<div class="stat" id="optionB">50%</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,10 +11,11 @@ connection.on("UpdateResults", function (results) {
|
||||
|
||||
document.getElementById("optionA").innerText = percentages.a + "%";
|
||||
document.getElementById("optionB").innerText = percentages.b + "%";
|
||||
var totalVotes = 'No votes yet';
|
||||
if (results.voteCount > 0) {
|
||||
var totalVotes = results.voteCount + (results.voteCount > 1 ? " votes" : " vote");
|
||||
document.getElementById("totalVotes").innerText = totalVotes;
|
||||
totalVotes = results.voteCount + (results.voteCount > 1 ? " votes" : " vote");
|
||||
}
|
||||
document.getElementById("totalVotes").innerText = totalVotes;
|
||||
|
||||
var bg1 = document.getElementById('background-stats-1');
|
||||
var bg2 = document.getElementById('background-stats-2');
|
||||
|
Loading…
Reference in New Issue
Block a user