From f46efd18d3efb72161d951245ed89a4e0cc08879 Mon Sep 17 00:00:00 2001 From: chamil321 Date: Thu, 6 Aug 2020 15:27:13 +0530 Subject: [PATCH] Add website resource with incremental --- distributor/src/distributor/website.bal | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/distributor/src/distributor/website.bal b/distributor/src/distributor/website.bal index da72bd5..ca25639 100644 --- a/distributor/src/distributor/website.bal +++ b/distributor/src/distributor/website.bal @@ -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"]