Compare commits
8 Commits
139320d2a2
...
master
Author | SHA1 | Date | |
---|---|---|---|
74c08b191a | |||
10d78b7497 | |||
ecfa12d3ed | |||
4b70470a86 | |||
aa52e42d9e | |||
d3cb16cefb | |||
4f3359a1c9 | |||
0d5e14e2e9 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
covid19-edmonton
|
||||
covid19-edmonton.exe
|
@ -3,8 +3,6 @@
|
||||
|
||||
[](https://drone.deadbeef.codes/steven/covid19-edmonton)
|
||||
|
||||
Currently deployed at https://edmonton.deadbeef.codes
|
||||
|
||||
I was bored and want to keep tabs on this in my area. Will download latest stats from alberta government website for COVID-19 and output the number of total and active cases in my area. Here's an example, it runs and nearly instantaneous spits out the current numbers.
|
||||
|
||||
![alt text][logo]
|
||||
@ -21,7 +19,7 @@ Simply invoke it with the -web flag and it will listen on port 8080
|
||||
|
||||
### Installation for Windows
|
||||
|
||||
1. [Download from releases page](https://deadbeef.codes/attachments/946604d4-ec45-45f9-afab-e2e33f9359d4) and run it. We're not fancy. I can't even afford a code signing certificate.
|
||||
Download from releases page and run it. We're not fancy. I can't even afford a code signing certificate.
|
||||
|
||||
### Building from Source
|
||||
|
||||
|
Binary file not shown.
BIN
example.png
BIN
example.png
Binary file not shown.
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 10 KiB |
5
main.go
5
main.go
@ -93,7 +93,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatalf("failed to get data from alberta government website: %v", err)
|
||||
}
|
||||
fmt.Printf("As of %s Mountain Time (the real time)\n\n", cache.UpdatedDate.Format("2006 Jan 02 15:04:05"))
|
||||
// CLI mode, print output to stdout
|
||||
fmt.Println("Edmonton Active: ", cache.Data.ActiveCasesEdmonton)
|
||||
fmt.Println("Edmonton Total: ", cache.Data.TotalCasesEdmonton)
|
||||
@ -137,7 +136,7 @@ func getUpdatedData() (*Cache, error) {
|
||||
return nil, fmt.Errorf("failed to parse data as json: %v", err)
|
||||
}
|
||||
|
||||
cache := &Cache{UpdatedDate: time.Now()}
|
||||
cache := &Cache{UpdatedDate: time.Now().Add(-time.Hour * 6)}
|
||||
|
||||
// count the cases
|
||||
for i := range data[2] {
|
||||
@ -164,7 +163,7 @@ func homePageHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("unable to serve page due to no cached data, possibly due to application still starting up, or AB government site down, or changed formatting - may need to review how page is parsed")
|
||||
return
|
||||
}
|
||||
if time.Now().After(cache.UpdatedDate.Add(cacheTimeout)) {
|
||||
if time.Now().Add(-time.Hour * 6).After(cache.UpdatedDate.Add(cacheTimeout)) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
tempCache, err := getUpdatedData() // Hold tempCache in case there's an error, we don't want to nullify our pointer to a working cache that has aged. We will proceed with aged data.
|
||||
if err != nil {
|
||||
|
@ -20,9 +20,20 @@
|
||||
padding-bottom: 5em;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#sourceCodeButton').on("click", function() {
|
||||
window.location = "https://deadbeef.codes/steven/covid19-edmonton"
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="sourceCodeButton" class="ui right floated button">
|
||||
Source Code
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<center>
|
||||
<h1 class="ui header">
|
||||
COVID-19 Dashboard
|
||||
@ -31,6 +42,7 @@
|
||||
</div>
|
||||
</h1>
|
||||
</center>
|
||||
|
||||
<div class="ui divider"></div>
|
||||
<div class="ui fluid four column doubling stackable grid container">
|
||||
<div class="column">
|
||||
|
Reference in New Issue
Block a user