time zone
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Steven Polley 2020-04-25 01:50:38 -06:00
parent 4b70470a86
commit ecfa12d3ed
1 changed files with 2 additions and 2 deletions

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 {