notifier panic fix

pull/805/head
hunterlong 4 years ago
parent e863de3f90
commit 8c0543a161

@ -1,3 +1,6 @@
# 0.90.65 (08-24-2020)
- Fixed issue with dashboard not logging in (notifier panic)
# 0.90.64 (08-18-2020)
- Modified max-width for container to 1012px, larger UI
- Added failure sparklines in the Services list view

@ -70,19 +70,19 @@ func (t *TimeVar) ToValues() ([]*TimeValue, error) {
}
// GraphData will return all hits or failures
func (g *GroupQuery) GraphData(by By) ([]*TimeValue, error) {
g.db = g.db.MultipleSelects(
g.db.SelectByTime(g.Group),
func (b *GroupQuery) GraphData(by By) ([]*TimeValue, error) {
b.db = b.db.MultipleSelects(
b.db.SelectByTime(b.Group),
by.String(),
).Group("timeframe").Order("timeframe", true)
caller, err := g.ToTimeValue()
caller, err := b.ToTimeValue()
if err != nil {
return nil, err
}
if g.FillEmpty {
return caller.FillMissing(g.Start, g.End)
if b.FillEmpty {
return caller.FillMissing(b.Start, b.End)
}
return caller.ToValues()
}
@ -90,8 +90,8 @@ func (g *GroupQuery) GraphData(by By) ([]*TimeValue, error) {
// ToTimeValue will format the SQL rows into a JSON format for the API.
// [{"timestamp": "2006-01-02T15:04:05Z", "amount": 468293}]
// TODO redo this entire function, use better SQL query to group by time
func (g *GroupQuery) ToTimeValue() (*TimeVar, error) {
rows, err := g.db.Rows()
func (b *GroupQuery) ToTimeValue() (*TimeVar, error) {
rows, err := b.db.Rows()
if err != nil {
return nil, err
}
@ -102,8 +102,8 @@ func (g *GroupQuery) ToTimeValue() (*TimeVar, error) {
if err := rows.Scan(&timeframe, &amount); err != nil {
log.Error(err, timeframe)
}
trueTime, _ := g.db.ParseTime(timeframe)
newTs := types.FixedTime(trueTime, g.Group)
trueTime, _ := b.db.ParseTime(timeframe)
newTs := types.FixedTime(trueTime, b.Group)
tv := &TimeValue{
Timeframe: newTs,
@ -111,7 +111,7 @@ func (g *GroupQuery) ToTimeValue() (*TimeVar, error) {
}
data = append(data, tv)
}
return &TimeVar{g, data}, nil
return &TimeVar{b, data}, nil
}
func (t *TimeVar) FillMissing(current, end time.Time) ([]*TimeValue, error) {

@ -14,8 +14,14 @@ func apiNotifiersHandler(w http.ResponseWriter, r *http.Request) {
var notifs []notifications.Notification
for _, n := range services.AllNotifiers() {
no := n.Select()
notif, _ := notifications.Find(no.Method)
notifs = append(notifs, *no.UpdateFields(notif))
notif, err := notifications.Find(no.Method)
if err != nil {
log.Errorln(err)
sendErrorJson(err, w, r)
return
}
updated := no.UpdateFields(notif)
notifs = append(notifs, *updated)
}
sort.Sort(notifications.NotificationOrder(notifs))
returnJson(notifs, w, r)

@ -132,6 +132,7 @@ func Router() *mux.Router {
api.Handle("/api/services/{id}/failures", scoped(apiServiceFailuresHandler)).Methods("GET")
api.Handle("/api/services/{id}/failures", authenticated(servicesDeleteFailuresHandler, false)).Methods("DELETE")
api.Handle("/api/services/{id}/hits", scoped(apiServiceHitsHandler)).Methods("GET")
api.Handle("/api/services/{id}/hits", authenticated(apiServiceHitsDeleteHandler, false)).Methods("DELETE")
// API SERVICE CHART DATA Routes
api.Handle("/api/services/{id}/hits_data", cached("30s", "application/json", apiServiceDataHandler)).Methods("GET")

@ -237,6 +237,19 @@ func apiServiceTimeDataHandler(w http.ResponseWriter, r *http.Request) {
returnJson(uptimeData, w, r)
}
func apiServiceHitsDeleteHandler(w http.ResponseWriter, r *http.Request) {
service, err := findService(r)
if err != nil {
sendErrorJson(err, w, r)
return
}
if err := service.AllHits().DeleteAll(); err != nil {
sendErrorJson(err, w, r)
return
}
sendJsonAction(service, "delete", w, r)
}
func apiServiceDeleteHandler(w http.ResponseWriter, r *http.Request) {
service, err := findService(r)
if err != nil {

@ -8,7 +8,7 @@ func (c *Checkin) LastHit() *CheckinHit {
func (c *Checkin) Hits() []*CheckinHit {
var hits []*CheckinHit
dbHits.Where("checkin = ?", c.Id).Order("DESC").Find(&hits)
dbHits.Where("checkin = ?", c.Id).Order("id DESC").Find(&hits)
c.AllHits = hits
return hits
}

@ -34,7 +34,7 @@ func (i *Incident) BeforeCreate() error {
}
func (i *Incident) AfterFind() {
db.Model(i).Related(&i.Updates).Order("DESC")
db.Model(i).Related(&i.Updates).Order("id DESC")
metrics.Query("incident", "find")
}

@ -1 +1 @@
0.90.64
0.90.65

Loading…
Cancel
Save