diff --git a/distributor/src/distributor/genhtml.bal b/distributor/src/distributor/genhtml.bal index 6e81c6f..bd29f9a 100644 --- a/distributor/src/distributor/genhtml.bal +++ b/distributor/src/distributor/genhtml.bal @@ -191,13 +191,13 @@ function generateParliamentaryResultHtml(string electionCode, map result, body += "
"; body += "
Total Valid Votes
" + "
" + commaFormatInt(result.summary.valid) + - "
" + result.summary.percent_valid + "%
"; + "
" + result.summary.percent_valid + "
"; body += "
Rejected Votes
" + "
" + commaFormatInt(result.summary.rejected) + - "
" + result.summary.percent_rejected + "%
"; + "
" + result.summary.percent_rejected + "
"; body += "
Total Polled
" + "
" + commaFormatInt(result.summary.polled) + - "
" + result.summary.percent_polled + "%
"; + "
" + result.summary.percent_polled + "
"; body += "
Registered No. of Electors
" + "
" + commaFormatInt(result.summary.electors) + "
"; diff --git a/distributor/src/distributor/save.bal b/distributor/src/distributor/save.bal index 8dd105b..18f1bb8 100644 --- a/distributor/src/distributor/save.bal +++ b/distributor/src/distributor/save.bal @@ -300,8 +300,6 @@ function addToPresidentialCumulative(map jm) returns PresidentialCumulativ accum.summary.valid += jm.summary.valid; accum.summary.rejected += jm.summary.rejected; accum.summary.polled += jm.summary.polled; - // don't add up electors from postal PDs as those are already in the district elsewhere - string pdCode = jm.pd_code; // check accum.summary.electors += jm.summary.electors; accum.summary.percent_valid = (accum.summary.polled == 0) ? "0.00" : io:sprintf("%.2f", accum.summary.valid*100.0/accum.summary.polled); accum.summary.percent_rejected = (accum.summary.polled == 0) ? "0.00" : io:sprintf("%.2f", accum.summary.rejected*100.0/accum.summary.polled); @@ -365,12 +363,10 @@ function addToParliamentaryCumulativeVotes(map jm) returns ParliamentaryCu summary.valid += jm.summary.valid; summary.rejected += jm.summary.rejected; summary.polled += jm.summary.polled; - // // don't add up electors from postal PDs as those are already in the district elsewhere - // string pdCode = jm.pd_code; // check summary.electors += jm.summary.electors; - summary.percent_valid = (accum.summary.polled == 0) ? "0.00" : io:sprintf("%.2f", accum.summary.valid*100.0/accum.summary.polled); - summary.percent_rejected = (accum.summary.polled == 0) ? "0.00" : io:sprintf("%.2f", accum.summary.rejected*100.0/accum.summary.polled); - summary.percent_polled = (accum.summary.electors == 0) ? "0.00" : io:sprintf("%.2f", accum.summary.polled*100.0/accum.summary.electors); + summary.percent_valid = (accum.summary.polled == 0) ? "0.00%" : string `${io:sprintf("%.2f", accum.summary.valid*100.0/accum.summary.polled)}%`; + summary.percent_rejected = (accum.summary.polled == 0) ? "0.00%" : string `${io:sprintf("%.2f", accum.summary.rejected*100.0/accum.summary.polled)}%`; + summary.percent_polled = (accum.summary.electors == 0) ? "0.00%" : string `${io:sprintf("%.2f", accum.summary.polled*100.0/accum.summary.electors)}%`; if accum.nadded == 0 { pr.forEach(x => accum.by_party.push(checkpanic ParliamentaryPartyResult.constructFrom(x))); @@ -384,7 +380,7 @@ function addToParliamentaryCumulativeVotes(map jm) returns ParliamentaryCu } else { int accumVoteCount = accum.by_party[i]?.vote_count + pr[i].vote_count; accum.by_party[i].vote_count = accumVoteCount; - accum.by_party[i].vote_percentage = (accum.summary.valid == 0) ? "0.00" : io:sprintf ("%.2f", ((accumVoteCount*1.0)/accum.summary.valid)); + accum.by_party[i].vote_percentage = (accum.summary.valid == 0) ? "0.00%" : string `${io:sprintf ("%.2f", ((accumVoteCount*100.0)/accum.summary.valid))}%`; } } } diff --git a/distributor/web/active-2020-07-26 b/distributor/web/active-2020-07-28-I similarity index 100% rename from distributor/web/active-2020-07-26 rename to distributor/web/active-2020-07-28-I diff --git a/distributor/web/info.txt b/distributor/web/info.txt index be5e764..b36d46c 100644 --- a/distributor/web/info.txt +++ b/distributor/web/info.txt @@ -2,15 +2,15 @@ ****** IMPORTANT ******* ** -** The latest version of the subscriber JAR is subscriber-20200726.jar +** The latest version of the subscriber JAR is subscriber-20200728-I.jar ** -** Available at https://github.com/ECLK/Results-Dist/releases/tag/v2020-07-26 +** Available at https://github.com/ECLK/Results-Dist/releases/tag/v2020-07-28-I ** ****** IMPORTANT ******* Run it as follows: -java -jar subscriber-20200726.jar [options] +java -jar subscriber-20200728-I.jar [options] where options are: -username=name my username for authentication diff --git a/subscriber/src/subscriber/constants.bal b/subscriber/src/subscriber/constants.bal index 1653061..859f514 100644 --- a/subscriber/src/subscriber/constants.bal +++ b/subscriber/src/subscriber/constants.bal @@ -9,7 +9,7 @@ const LEVEL_NF = "NATIONAL-FINAL"; const WANT_IMAGE = "image=true"; const WANT_AWAIT_RESULTS = "await=true"; -const MY_VERSION = "2020-07-26"; +const MY_VERSION = "2020-07-28-I"; const UNDERSOCRE = "_"; const COLON = ":"; diff --git a/subscriber/src/subscriber/genhtml.bal b/subscriber/src/subscriber/genhtml.bal index 406e724..a5ccde0 100644 --- a/subscriber/src/subscriber/genhtml.bal +++ b/subscriber/src/subscriber/genhtml.bal @@ -175,13 +175,13 @@ function generateParliamentaryResultHtml(string electionCode, map result, body += "
"; body += "
Total Valid Votes
" + "
" + commaFormatInt(result.summary.valid) + - "
" + result.summary.percent_valid + "%
"; + "
" + result.summary.percent_valid + "
"; body += "
Rejected Votes
" + "
" + commaFormatInt(result.summary.rejected) + - "
" + result.summary.percent_rejected + "%
"; + "
" + result.summary.percent_rejected + "
"; body += "
Total Polled
" + "
" + commaFormatInt(result.summary.polled) + - "
" + result.summary.percent_polled + "%
"; + "
" + result.summary.percent_polled + "
"; body += "
Registered No. of Electors
" + "
" + commaFormatInt(result.summary.electors) + "
"; diff --git a/subscriber/src/subscriber/subscriber.bal b/subscriber/src/subscriber/subscriber.bal index 82a89f7..33debb4 100644 --- a/subscriber/src/subscriber/subscriber.bal +++ b/subscriber/src/subscriber/subscriber.bal @@ -131,13 +131,13 @@ public function main (string? username = (), // my username http:WebSocketClient wsClientEp = new (wsUrl, config = { callbackService: callbackService, - customHeaders: headers, - retryConfig: { - intervalInMillis: 3000, - maxCount: 10, - backOffFactor: 1.5, - maxWaitIntervalInMillis: 20000 - } + customHeaders: headers + // retryConfig: { + // intervalInMillis: 3000, + // maxCount: 10, + // backOffFactor: 1.5, + // maxWaitIntervalInMillis: 20000 + // } }); if wsClientEp.isOpen() { diff --git a/subscriber/src/subscriber/tests/main_test.bal b/subscriber/src/subscriber/tests/main_test.bal index 7bfff75..6ccab8f 100644 --- a/subscriber/src/subscriber/tests/main_test.bal +++ b/subscriber/src/subscriber/tests/main_test.bal @@ -49,17 +49,17 @@ function testRE_VI(string filePath, int fooCount, int barCount, int bazCount, in map party = >parties[0]; test:assertEquals(party["party_name"], "Foo foo"); test:assertEquals(party["vote_count"], fooCount); - test:assertEquals(party["vote_percentage"], io:sprintf("%.2f", ((fooCount*1.0)/valid))); + test:assertEquals(party["vote_percentage"], string `${io:sprintf("%.2f", ((fooCount*100.0)/valid))}%`); party = >parties[1]; test:assertEquals(party["party_name"], "Bar bar"); test:assertEquals(party["vote_count"], barCount); - test:assertEquals(party["vote_percentage"], io:sprintf("%.2f", ((barCount*1.0)/valid))); + test:assertEquals(party["vote_percentage"], string `${io:sprintf("%.2f", ((barCount*100.0)/valid))}%`); party = >parties[2]; test:assertEquals(party["party_name"], "Baz baz"); test:assertEquals(party["vote_count"], bazCount); - test:assertEquals(party["vote_percentage"], io:sprintf("%.2f", ((bazCount*1.0)/valid))); + test:assertEquals(party["vote_percentage"], string `${io:sprintf("%.2f", ((bazCount*100.0)/valid))}%`); map edSummary = >value.summary; test:assertEquals(edSummary["valid"], valid); diff --git a/testdriver/src/testdriver/gen_fake_parliamentary.bal b/testdriver/src/testdriver/gen_fake_parliamentary.bal index fa7b1c3..7a55820 100644 --- a/testdriver/src/testdriver/gen_fake_parliamentary.bal +++ b/testdriver/src/testdriver/gen_fake_parliamentary.bal @@ -14,7 +14,7 @@ function genFakeParliamentary() { "party_code": "Foo", "party_name": "Foo foo", "vote_count": 15, - "vote_percentage": 0.17, + "vote_percentage": "16.67%", "seat_count": 0, "national_list_seat_count": 0 }, @@ -22,7 +22,7 @@ function genFakeParliamentary() { "party_code": "Bar", "party_name": "Bar bar", "vote_count": 65, - "vote_percentage": 0.72, + "vote_percentage": "72.22%", "seat_count": 0, "national_list_seat_count": 0 }, @@ -30,7 +30,7 @@ function genFakeParliamentary() { "party_code": "Baz", "party_name": "Baz baz", "vote_count": 10, - "vote_percentage": 0.11, + "vote_percentage": "11.11%", "seat_count": 0, "national_list_seat_count": 0 } @@ -56,7 +56,7 @@ function genFakeParliamentary() { "party_code": "Foo", "party_name": "Foo foo", "vote_count": 90, - "vote_percentage": 0.6, + "vote_percentage": "60.00%", "seat_count": 0, "national_list_seat_count": 0 }, @@ -64,7 +64,7 @@ function genFakeParliamentary() { "party_code": "Bar", "party_name": "Bar bar", "vote_count": 35, - "vote_percentage": 0.23, + "vote_percentage": "23.33%", "seat_count": 0, "national_list_seat_count": 0 }, @@ -72,7 +72,7 @@ function genFakeParliamentary() { "party_code": "Baz", "party_name": "Baz baz", "vote_count": 25, - "vote_percentage": 0.17, + "vote_percentage": "16.67%", "seat_count": 0, "national_list_seat_count": 0 } @@ -98,7 +98,7 @@ function genFakeParliamentary() { "party_code": "Foo", "party_name": "Foo foo", "vote_count": 10, - "vote_percentage": 0.46, + "vote_percentage": "45.45%", "seat_count": 0, "national_list_seat_count": 0 }, @@ -106,7 +106,7 @@ function genFakeParliamentary() { "party_code": "Bar", "party_name": "Bar bar", "vote_count": 0, - "vote_percentage": 0.00, + "vote_percentage": "0.00%", "seat_count": 0, "national_list_seat_count": 0 }, @@ -114,7 +114,7 @@ function genFakeParliamentary() { "party_code": "Baz", "party_name": "Baz baz", "vote_count": 12, - "vote_percentage": 0.54, + "vote_percentage": "54.55%", "seat_count": 0, "national_list_seat_count": 0 } @@ -140,7 +140,7 @@ function genFakeParliamentary() { "party_code": "Foo", "party_name": "Foo foo", "vote_count": 10, - "vote_percentage": 0.13, + "vote_percentage": "12.50%", "seat_count": 0, "national_list_seat_count": 0 }, @@ -148,7 +148,7 @@ function genFakeParliamentary() { "party_code": "Bar", "party_name": "Bar bar", "vote_count": 50, - "vote_percentage": 0.63, + "vote_percentage": "62.50%", "seat_count": 0, "national_list_seat_count": 0 }, @@ -156,7 +156,7 @@ function genFakeParliamentary() { "party_code": "Baz", "party_name": "Baz baz", "vote_count": 20, - "vote_percentage": 0.25, + "vote_percentage": "25.00%", "seat_count": 0, "national_list_seat_count": 0 } @@ -182,7 +182,7 @@ function genFakeParliamentary() { "party_code": "Foo", "party_name": "Foo foo", "vote_count": 50, - "vote_percentage": 0.55, + "vote_percentage": "55.56%", "seat_count": 0, "national_list_seat_count": 0 }, @@ -190,7 +190,7 @@ function genFakeParliamentary() { "party_code": "Bar", "party_name": "Bar bar", "vote_count": 20, - "vote_percentage": 0.22, + "vote_percentage": "22.22%", "seat_count": 0, "national_list_seat_count": 0 }, @@ -198,7 +198,7 @@ function genFakeParliamentary() { "party_code": "Baz", "party_name": "Baz baz", "vote_count": 20, - "vote_percentage": 0.22, + "vote_percentage": "22.22%", "seat_count": 0, "national_list_seat_count": 0 } @@ -222,7 +222,7 @@ function genFakeParliamentary() { "party_code": "Baz", "party_name": "Baz baz", "vote_count": 0, - "vote_percentage": 0.00, + "vote_percentage": "0.00%", "seat_count": 3, "national_list_seat_count": 0 }, @@ -230,7 +230,7 @@ function genFakeParliamentary() { "party_code": "Foo", "party_name": "Foo foo", "vote_count": 0, - "vote_percentage": 0.00, + "vote_percentage": "0.00%", "seat_count": 10, "national_list_seat_count": 0 }, @@ -254,7 +254,7 @@ function genFakeParliamentary() { "party_code": "Foo", "party_name": "Foo foo", "vote_count": 0, - "vote_percentage": 0.00, + "vote_percentage": "0.00%", "seat_count": 8, "national_list_seat_count": 0 }, @@ -262,7 +262,7 @@ function genFakeParliamentary() { "party_code": "Bar", "party_name": "Bar bar", "vote_count": 0, - "vote_percentage": 0.00, + "vote_percentage": "0.00%", "seat_count": 20, "national_list_seat_count": 0 }, @@ -284,7 +284,7 @@ function genFakeParliamentary() { "party_code": "Bar", "party_name": "Bar bar", "vote_count": 12540, - "vote_percentage": 0.33, + "vote_percentage": "32.79%", "seat_count": 75, "national_list_seat_count": 0 }, @@ -292,7 +292,7 @@ function genFakeParliamentary() { "party_code": "Baz", "party_name": "Baz baz", "vote_count": 7500, - "vote_percentage": 0.20, + "vote_percentage": "19.61%", "seat_count": 25, "national_list_seat_count": 0 }, @@ -300,7 +300,7 @@ function genFakeParliamentary() { "party_code": "Foo", "party_name": "Foo foo", "vote_count": 18200, - "vote_percentage": 0.48, + "vote_percentage": "47.59%", "seat_count": 100, "national_list_seat_count": 0 } @@ -322,7 +322,7 @@ function genFakeParliamentary() { "party_code": "Baz", "party_name": "Baz baz", "vote_count": 7500, - "vote_percentage": 0.20, + "vote_percentage": "19.61%", "seat_count": 25, "national_list_seat_count": 4 }, @@ -330,7 +330,7 @@ function genFakeParliamentary() { "party_code": "Foo", "party_name": "Foo foo", "vote_count": 18200, - "vote_percentage": 0.48, + "vote_percentage": "47.59%", "seat_count": 100, "national_list_seat_count": 12 }, @@ -338,7 +338,7 @@ function genFakeParliamentary() { "party_code": "Bar", "party_name": "Bar bar", "vote_count": 12540, - "vote_percentage": 0.33, + "vote_percentage": "32.79%", "seat_count": 75, "national_list_seat_count": 9 } diff --git a/testdriver/src/testdriver/sendparliamentaryresults.bal b/testdriver/src/testdriver/sendparliamentaryresults.bal index 46a1c50..c44d1bc 100644 --- a/testdriver/src/testdriver/sendparliamentaryresults.bal +++ b/testdriver/src/testdriver/sendparliamentaryresults.bal @@ -62,7 +62,7 @@ function updateByParty(json[] byPartyJson) returns error? { json val = party["vote_percentage"]; if val is float { - party["vote_percentage"] = io:sprintf ("%.2f", val); + party["vote_percentage"] = string `${io:sprintf ("%.2f", val * 100.0)}%`; } else { // already a string so let it go } @@ -72,9 +72,9 @@ function updateByParty(json[] byPartyJson) returns error? { function updateSummary(map result) returns error? { // set the percentages in the summary map summary = >result.summary; - summary["percent_valid"] = (result.summary.polled == 0) ? "0.00" : io:sprintf("%.2f", result.summary.valid*100.0/result.summary.polled); - summary["percent_rejected"] = (result.summary.polled == 0) ? "0.00" : io:sprintf("%.2f", result.summary.rejected*100.0/result.summary.polled); - summary["percent_polled"] = (result.summary.electors == 0) ? "0.00" : io:sprintf("%.2f", result.summary.polled*100.0/result.summary.electors); + summary["percent_valid"] = (result.summary.polled == 0) ? "0.00%" : string `${io:sprintf("%.2f", result.summary.valid*100.0/result.summary.polled)}%`; + summary["percent_rejected"] = (result.summary.polled == 0) ? "0.00%" : string `${io:sprintf("%.2f", result.summary.rejected*100.0/result.summary.polled)}%`; + summary["percent_polled"] = (result.summary.electors == 0) ? "0.00%" : string `${io:sprintf("%.2f", result.summary.polled*100.0/result.summary.electors)}%`; } diff --git a/testdriver/src/testdriver/sendresults.bal b/testdriver/src/testdriver/sendresults.bal index f6cae25..e1869d1 100644 --- a/testdriver/src/testdriver/sendresults.bal +++ b/testdriver/src/testdriver/sendresults.bal @@ -196,7 +196,7 @@ function createEDResult (string resultType, map>[] results, map[ distByParty[i]["votes2nd"] = votes2nd_by_party[i]; distByParty[i]["votes3rd"] = votes3rd_by_party[i]; } - distByParty[i]["vote_percentage"] = (distSummary.valid == 0) ? "0.00" : io:sprintf ("%.2f", votes_by_party[i]*100.0/distSummary.valid); + distByParty[i]["vote_percentage"] = (distSummary.valid == 0) ? "0.00" : io:sprintf("%.2f", votes_by_party[i]*100.0/distSummary.valid); } // set the percentages in the summary @@ -279,13 +279,13 @@ function createNationalResult (string resultType, map>[] results, map< natByParty[i]["votes2nd"] = votes2nd_by_party[i]; natByParty[i]["votes3rd"] = votes3rd_by_party[i]; } - natByParty[i]["vote_percentage"] = (natSummary.valid == 0) ? "0.00" : io:sprintf ("%.2f", votes_by_party[i]*100.0/natSummary.valid); + natByParty[i]["vote_percentage"] = (natSummary.valid == 0) ? "0.00" : io:sprintf("%.2f", votes_by_party[i]*100.0/natSummary.valid); } // set the percentages in the summary natSummary.percent_valid = (natSummary.polled == 0) ? "0.00" : io:sprintf("%.2f", natSummary.valid*100.0/natSummary.polled); natSummary.percent_rejected = (natSummary.polled == 0) ? "0.00" : io:sprintf("%.2f", natSummary.rejected*100.0/natSummary.polled); - natSummary.percent_polled = (natSummary.electors == 0) ? "0.00" : io:sprintf("%.2f", natSummary.polled*100.0/natSummary.electors); + natSummary.percent_polled = (natSummary.electors == 0) ? "0.00" : io:sprintf("%.2f", natSummary.polled*100.0/natSummary.electors); return { 'type: resultType,