Compare commits

...

8 Commits

Author SHA1 Message Date
74c08b191a Update 'README.md'
All checks were successful
continuous-integration/drone/push Build is passing
2020-04-28 18:17:54 +00:00
10d78b7497 remove artifcats
All checks were successful
continuous-integration/drone/push Build is passing
2020-04-25 01:57:27 -06:00
ecfa12d3ed time zone
All checks were successful
continuous-integration/drone/push Build is passing
2020-04-25 01:50:38 -06:00
4b70470a86 remove redundant output
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-04-25 01:41:45 -06:00
aa52e42d9e update example 2020-04-25 01:41:36 -06:00
d3cb16cefb Add source code link button
All checks were successful
continuous-integration/drone/push Build is passing
2020-04-25 01:33:55 -06:00
4f3359a1c9 Remove link to releases download 2020-04-25 01:33:43 -06:00
0d5e14e2e9 Add git ignore 2020-04-25 01:33:28 -06:00
6 changed files with 17 additions and 6 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
covid19-edmonton
covid19-edmonton.exe

View File

@ -3,8 +3,6 @@
[![Build Status](https://drone.deadbeef.codes/api/badges/steven/covid19-edmonton/status.svg)](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.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -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 {

View File

@ -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">