mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-21 23:43:27 +01:00
Minor improvements
This commit is contained in:
parent
4203355edc
commit
f73e8a56ef
@ -201,8 +201,7 @@ func (s *Store) Insert(service *core.Service, result *core.Result) {
|
||||
// based on result.Success.
|
||||
numberOfEvents, err := s.getNumberOfEventsByServiceID(tx, serviceID)
|
||||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
return
|
||||
log.Printf("[database][Insert] Failed to retrieve total number of events for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||
}
|
||||
if numberOfEvents == 0 {
|
||||
// There's no events yet, which means we need to add the EventStart and the first healthy/unhealthy event
|
||||
@ -253,14 +252,14 @@ func (s *Store) Insert(service *core.Service, result *core.Result) {
|
||||
// Second, we need to insert the result.
|
||||
err = s.insertResult(tx, serviceID, result)
|
||||
if err != nil {
|
||||
// Silently fail
|
||||
log.Printf("[database][Insert] Failed to insert result for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||
_ = tx.Rollback()
|
||||
return
|
||||
}
|
||||
// Clean up old results
|
||||
numberOfResults, err := s.getNumberOfResultsByServiceID(tx, serviceID)
|
||||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
return
|
||||
log.Printf("[database][Insert] Failed to retrieve total number of results for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||
}
|
||||
if numberOfResults > core.MaximumNumberOfResults*2 {
|
||||
err = s.deleteOldServiceResults(tx, serviceID)
|
||||
|
Loading…
Reference in New Issue
Block a user