Skip to content

Commit

Permalink
Merge pull request #1749 from gobitfly/BIDS-1453/SomeEpochError
Browse files Browse the repository at this point in the history
(BIDS-1453) Some epoch errors which should be avoid / switched to war…
  • Loading branch information
guybrush authored Jan 24, 2023
2 parents 638adac + 69f104d commit 4528b6b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions handlers/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func Epoch(w http.ResponseWriter, r *http.Request) {
if err != nil {
SetPageDataTitle(data, fmt.Sprintf("Epoch %v", epochString))
data.Meta.Path = "/epoch/" + epochString
logger.Errorf("error parsing epoch index %v: %v", epochString, err)

if handleTemplateError(w, r, "epoch.go", "Epoch", "parse epochString", epochNotFoundTemplate.ExecuteTemplate(w, "layout", data)) != nil {
return // an error has occurred and was processed
Expand Down Expand Up @@ -156,10 +155,15 @@ func Epoch(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Internal server error", http.StatusInternalServerError)
return
}
err = db.ReaderDb.Get(&epochPageData.PreviousEpoch, "SELECT epoch FROM epochs WHERE epoch < $1 ORDER BY epoch DESC LIMIT 1", epochPageData.Epoch)
if err != nil {
logger.Errorf("error retrieving previous epoch for epoch %v: %v", epochPageData.Epoch, err)

if epochPageData.Epoch == 0 {
epochPageData.PreviousEpoch = 0
} else {
err = db.ReaderDb.Get(&epochPageData.PreviousEpoch, "SELECT epoch FROM epochs WHERE epoch < $1 ORDER BY epoch DESC LIMIT 1", epochPageData.Epoch)
if err != nil {
logger.Errorf("error retrieving previous epoch for epoch %v: %v", epochPageData.Epoch, err)
epochPageData.PreviousEpoch = 0
}
}

data.Data = epochPageData
Expand Down

0 comments on commit 4528b6b

Please sign in to comment.