This is a simple web app that was a weekend hack that tells you the the number of Covid cases in your suburb in Sydney, New South Wales.
- Java 11
- Spring boot
- Lombok
- Vanilla Javascript ( no framework )
You can also run it from the command line (or command prompt for windows users).
git clone https://github.com/cptdanko/localCovidCases.git
cd localCovidCases
mvn clean install
mvn spring-boot:run
open browser and enter http://localhost:5000/
This project has only been tested in IntelliJ CE IDE.
- Clone the repository
- Launch IntelliJ
- Import the project
- Click on run from the IDE interface to launch the app
- Enter http://localhost:5000/ in your browser
You are free to use whichever IDE you prefer. Should you use a different IDE then please create a document with setup instructions for that IDE and create a PR for this repo.
This project uses the data source Covid cases by likely source of infection from the NSW health website.
2020-03-02,2077,Locally acquired - linked to known case or cluster,X760,Northern Sydney,14000,Hornsby (A)
2020-03-02,2073,Locally acquired - no links to known case or cluster,X760,Northern Sydney,14500,Ku-ring-gai (A)
2020-03-02,2217,Overseas,X720,South Eastern Sydney,10500,Bayside (A)
The API exposes 3 endpoints
- /raw
- /byPostcode/{postcode}
- /byPostcode/{postcode}/aggregate
The current UI uses the last endpoint to retrieve and display the data. The UI has an index.html file and index.js file that has the Javascript code to generate the UI elements. Here's the code to dynamicall generate the UI
const parent = document.getElementById("summaryCards");
parent.innerHTML = "";
//we should have a map of case numbers by date
for (const [key, value] of dateMap) {
const card = document.createElement("div");
card.className = "resultCard";
const summaryDiv = document.createElement("div");
summaryDiv.style.textAlign = "center";
summaryDiv.innerHTML = `<p> <b>${value.total}</b> case(s) on
<b>${formatDate(key)}</b></p>
<hr />`;
card.appendChild(summaryDiv);
const dataPointsDiv = document.createElement("div");
value.dataPoints.forEach(dp => {
const detailDiv = document.createElement("div");
detailDiv.innerHTML = `<p> <b>${dp.count}</b> cases are
<b><i>${dp.source}</i> </b> </p>
<hr />`;
card.appendChild(detailDiv);
});
parent.appendChild(card);
}
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Date;
@NoArgsConstructor
@Getter
@Setter
public class CasesByDate {
private Date date;
private int count;
private String lhdName;
private String source;
}
See Lombok in action above This method of the source code shows the logic to aggregate parsed data.
Checkout this blog for more "how-to" code samples, tutorials and just info on how to solve problems.
If you like what I am doing, you can buy me a coffee
Click on the next link for more info on the 13+ year software engineering career journey of the author.