Skip to content

Commit

Permalink
Merge pull request #183 from chamil321/subs
Browse files Browse the repository at this point in the history
Add website resource with incremental
  • Loading branch information
chamil321 authored Aug 6, 2020
2 parents c0d469f + f46efd1 commit 6bdd0bf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions distributor/src/distributor/website.bal
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ service mediaWebsite on mediaListener {
return caller->ok(results);
}

resource function allresultswithincremental(http:Caller caller, http:Request req) returns error? {
json[] results = [];
// return results in reverse order
int i = resultsCache.length();
if electionType == ELECTION_TYPE_PARLIAMENTARY {
while i > 0 { // show non-incremental results in reverse order of release
i = i - 1;
results.push(resultsCache[i].jsonResult);
}
} else {
while i > 0 { // show non-incremental results in reverse order of release
i = i - 1;
if resultsCache[i].jsonResult.level != "NATIONAL-INCREMENTAL" {
results.push(resultsCache[i].jsonResult);
}
}
}
return caller->ok(results);
}

@http:ResourceConfig {
path: "/result/{election}/{seqNo}",
methods: ["GET"]
Expand Down

0 comments on commit 6bdd0bf

Please sign in to comment.