mirror of https://github.com/statping/statping
notifier panic fix
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)
|
# 0.90.64 (08-18-2020)
|
||||||
- Modified max-width for container to 1012px, larger UI
|
- Modified max-width for container to 1012px, larger UI
|
||||||
- Added failure sparklines in the Services list view
|
- 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
|
// GraphData will return all hits or failures
|
||||||
func (g *GroupQuery) GraphData(by By) ([]*TimeValue, error) {
|
func (b *GroupQuery) GraphData(by By) ([]*TimeValue, error) {
|
||||||
g.db = g.db.MultipleSelects(
|
b.db = b.db.MultipleSelects(
|
||||||
g.db.SelectByTime(g.Group),
|
b.db.SelectByTime(b.Group),
|
||||||
by.String(),
|
by.String(),
|
||||||
).Group("timeframe").Order("timeframe", true)
|
).Group("timeframe").Order("timeframe", true)
|
||||||
|
|
||||||
caller, err := g.ToTimeValue()
|
caller, err := b.ToTimeValue()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.FillEmpty {
|
if b.FillEmpty {
|
||||||
return caller.FillMissing(g.Start, g.End)
|
return caller.FillMissing(b.Start, b.End)
|
||||||
}
|
}
|
||||||
return caller.ToValues()
|
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.
|
// ToTimeValue will format the SQL rows into a JSON format for the API.
|
||||||
// [{"timestamp": "2006-01-02T15:04:05Z", "amount": 468293}]
|
// [{"timestamp": "2006-01-02T15:04:05Z", "amount": 468293}]
|
||||||
// TODO redo this entire function, use better SQL query to group by time
|
// TODO redo this entire function, use better SQL query to group by time
|
||||||
func (g *GroupQuery) ToTimeValue() (*TimeVar, error) {
|
func (b *GroupQuery) ToTimeValue() (*TimeVar, error) {
|
||||||
rows, err := g.db.Rows()
|
rows, err := b.db.Rows()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,8 @@ func (g *GroupQuery) ToTimeValue() (*TimeVar, error) {
|
||||||
if err := rows.Scan(&timeframe, &amount); err != nil {
|
if err := rows.Scan(&timeframe, &amount); err != nil {
|
||||||
log.Error(err, timeframe)
|
log.Error(err, timeframe)
|
||||||
}
|
}
|
||||||
trueTime, _ := g.db.ParseTime(timeframe)
|
trueTime, _ := b.db.ParseTime(timeframe)
|
||||||
newTs := types.FixedTime(trueTime, g.Group)
|
newTs := types.FixedTime(trueTime, b.Group)
|
||||||
|
|
||||||
tv := &TimeValue{
|
tv := &TimeValue{
|
||||||
Timeframe: newTs,
|
Timeframe: newTs,
|
||||||
|
@ -111,7 +111,7 @@ func (g *GroupQuery) ToTimeValue() (*TimeVar, error) {
|
||||||
}
|
}
|
||||||
data = append(data, tv)
|
data = append(data, tv)
|
||||||
}
|
}
|
||||||
return &TimeVar{g, data}, nil
|
return &TimeVar{b, data}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TimeVar) FillMissing(current, end time.Time) ([]*TimeValue, error) {
|
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
|
var notifs []notifications.Notification
|
||||||
for _, n := range services.AllNotifiers() {
|
for _, n := range services.AllNotifiers() {
|
||||||
no := n.Select()
|
no := n.Select()
|
||||||
notif, _ := notifications.Find(no.Method)
|
notif, err := notifications.Find(no.Method)
|
||||||
notifs = append(notifs, *no.UpdateFields(notif))
|
if err != nil {
|
||||||
|
log.Errorln(err)
|
||||||
|
sendErrorJson(err, w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
updated := no.UpdateFields(notif)
|
||||||
|
notifs = append(notifs, *updated)
|
||||||
}
|
}
|
||||||
sort.Sort(notifications.NotificationOrder(notifs))
|
sort.Sort(notifications.NotificationOrder(notifs))
|
||||||
returnJson(notifs, w, r)
|
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", scoped(apiServiceFailuresHandler)).Methods("GET")
|
||||||
api.Handle("/api/services/{id}/failures", authenticated(servicesDeleteFailuresHandler, false)).Methods("DELETE")
|
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", scoped(apiServiceHitsHandler)).Methods("GET")
|
||||||
|
api.Handle("/api/services/{id}/hits", authenticated(apiServiceHitsDeleteHandler, false)).Methods("DELETE")
|
||||||
|
|
||||||
// API SERVICE CHART DATA Routes
|
// API SERVICE CHART DATA Routes
|
||||||
api.Handle("/api/services/{id}/hits_data", cached("30s", "application/json", apiServiceDataHandler)).Methods("GET")
|
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)
|
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) {
|
func apiServiceDeleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
service, err := findService(r)
|
service, err := findService(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -8,7 +8,7 @@ func (c *Checkin) LastHit() *CheckinHit {
|
||||||
|
|
||||||
func (c *Checkin) Hits() []*CheckinHit {
|
func (c *Checkin) Hits() []*CheckinHit {
|
||||||
var 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
|
c.AllHits = hits
|
||||||
return hits
|
return hits
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ func (i *Incident) BeforeCreate() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Incident) AfterFind() {
|
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")
|
metrics.Query("incident", "find")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.90.64
|
0.90.65
|
||||||
|
|
Loading…
Reference in New Issue