diff --git a/subscriber/src/subscriber/genhtml.bal b/subscriber/src/subscriber/genhtml.bal
index 4b44b36..5f98583 100644
--- a/subscriber/src/subscriber/genhtml.bal
+++ b/subscriber/src/subscriber/genhtml.bal
@@ -1,6 +1,6 @@
-import ballerina/time;
-import ballerina/math;
import ballerina/lang.'string;
+import ballerina/math;
+import ballerina/time;
map electionCode2Name = {
"2019PRE": "PRESIDENTIAL ELECTION - 16/11/2019",
@@ -22,7 +22,7 @@ map electionCode2Name = {
"2015-PRE-REPLAY-015": "PRESIDENTIAL ELECTION - 08/01/2015 RESULT REPLAY"
};
-function generateHtml (string electionCode, map result, boolean sorted) returns string|error {
+function generateHtml(string electionCode, map result, boolean sorted) returns string|error {
string electionName = electionCode2Name[electionCode] ?: "Presidential Election - TEST";
string timeNow = check time:format(time:currentTime(), "yyyy-MM-dd'T'HH:mm:ss.SSSZ");
string head = "";
@@ -71,7 +71,7 @@ function generateHtml (string electionCode, map result, boolean sorted) re
return "" + head + body + "";
}
-function sortPartyResults (json[] unsorted) returns json[] {
+function sortPartyResults(json[] unsorted) returns json[] {
return unsorted.sort(function (json r1, json r2) returns int {
int n1 = r1.votes;
int n2 = r2.votes;
@@ -79,7 +79,7 @@ function sortPartyResults (json[] unsorted) returns json[] {
});
}
-function commaFormatInt (int n) returns string {
+function commaFormatInt(int n) returns string {
string minus = n < 0 ? "-" : "";
int num = math:absInt(n);
string numStr = num.toString();
@@ -92,6 +92,6 @@ function commaFormatInt (int n) returns string {
if numStr.length() > 0 {
parts.unshift(numStr);
}
- string res = 'string:'join(",", ... parts);
+ string res = 'string:'join(",", ...parts);
return minus + res;
}
diff --git a/subscriber/src/subscriber/save.bal b/subscriber/src/subscriber/save.bal
index 43ed571..e7b2ba2 100644
--- a/subscriber/src/subscriber/save.bal
+++ b/subscriber/src/subscriber/save.bal
@@ -1,8 +1,8 @@
import ballerina/http;
import ballerina/io;
import ballerina/log;
-import ballerina/xmlutils;
import ballerina/stringutils as su;
+import ballerina/xmlutils;
const PRESIDENTIAL_RESULT = "PRESIDENTIAL-FIRST";
const LEVEL_PD = "POLLING-DIVISION";
diff --git a/subscriber/src/subscriber/subscriber.bal b/subscriber/src/subscriber/subscriber.bal
index 5ba83d2..b5abb18 100644
--- a/subscriber/src/subscriber/subscriber.bal
+++ b/subscriber/src/subscriber/subscriber.bal
@@ -45,19 +45,19 @@ http:OutboundAuthConfig? auth = ();
http:Client? imageClient = ();
// what formats does the user want results saved in?
-public function main (string secret, // secret to send to the hub
- string? username = (), // my username
- string? password = (), // my password
- boolean await = false, // do I want the await results notification?
- boolean 'json = false, // do I want json?
- boolean 'xml = false, // do I want xml?
- boolean image = false, // do I want the image?
- boolean html = false, // do I want HTML?
- boolean sorted = true, // do I want HTML results sorted highest to lowest
- boolean wantCode = false, // do I want electionCode in the filename
- string homeURL = "https://resultstest.ecdev.opensource.lk", // where do I subscribe at
- int port = 1111, // port I'm going to open
- string myURL = "" // how to reach me over the internet
+public function main(string secret, // secret to send to the hub
+ string? username = (), // my username
+ string? password = (), // my password
+ boolean await = false, // do I want the await results notification?
+ boolean 'json = false, // do I want json?
+ boolean 'xml = false, // do I want xml?
+ boolean image = false, // do I want the image?
+ boolean html = false, // do I want HTML?
+ boolean sorted = true, // do I want HTML results sorted highest to lowest
+ boolean wantCode = false, // do I want electionCode in the filename
+ string homeURL = "https://resultstest.ecdev.opensource.lk", // where do I subscribe at
+ int port = 1111, // port I'm going to open
+ string myURL = "" // how to reach me over the internet
) returns error? {
subscriberSecret = <@untainted> secret;
subscriberPublicUrl = <@untainted> (myURL == "" ? string `http://localhost:${port}` : myURL);
@@ -65,18 +65,18 @@ public function main (string secret, // secret to send to the hub
hub = <@untainted> homeURL + "/websub/hub";
// check what format the user wants results in
- wantJson = <@untainted>'json;
- wantXml = <@untainted>'xml;
- wantHtml = <@untainted>html;
+ wantJson = <@untainted> 'json;
+ wantXml = <@untainted> 'xml;
+ wantHtml = <@untainted> html;
if !(wantJson || wantXml || wantHtml) {
// default to giving json
wantJson = true;
}
- sortedHtml = <@untainted>sorted;
+ sortedHtml = <@untainted> sorted;
// set up auth
if (username is string && password is string) {
- auth:OutboundBasicAuthProvider outboundBasicAuthProvider = new ({
+ auth:OutboundBasicAuthProvider outboundBasicAuthProvider = new({
username: <@untainted> username,
password: <@untainted> password
});
@@ -154,7 +154,6 @@ public function main (string secret, // secret to send to the hub
error? pingStatus = ping:ping();
if !(pingStatus is ()) {
log:printError("Error pinging on await notification", pingStatus);
-
}
} else {
log:printError("Expected text payload, received:" + textPayload.toString());
@@ -165,7 +164,7 @@ public function main (string secret, // secret to send to the hub
}
if image {
- imageClient = <@untainted> new (homeURL, {auth: auth});
+ imageClient = <@untainted> new(homeURL, {auth: auth});
// attach the image subscriber
service imageSubscriberService = @websub:SubscriberServiceConfig {