Compare commits

...

3 Commits
2.0 ... master

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
3 changed files with 2 additions and 4 deletions

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) [![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. 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] ![alt text][logo]

Binary file not shown.

View File

@ -136,7 +136,7 @@ func getUpdatedData() (*Cache, error) {
return nil, fmt.Errorf("failed to parse data as json: %v", err) 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 // count the cases
for i := range data[2] { for i := range data[2] {
@ -163,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") 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 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) 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. 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 { if err != nil {