···9292 if err != nil {
9393 return fmt.Errorf("unable to ping: %w", err)
9494 }
9595-9695 statusCode := statusCode(res.StatusCode)
9796 // let's retry at least once if the status code is not successful.
9897 if !statusCode.IsSuccessful() && called < 2 {
···109108 Message: res.Message,
110109 CronTimestamp: req.CronTimestamp,
111110 })
112112- } else if req.Status == "error" && statusCode.IsSuccessful() {
111111+ }
112112+113113+ if req.Status == "error" && statusCode.IsSuccessful() {
113114 // Q: Why here we check the data before updating the status in this scenario?
114115 checker.UpdateStatus(ctx, checker.UpdateData{
115116 MonitorId: req.MonitorID,
···120121121122 })
122123 }
123123-124124 if err := tinybirdClient.SendEvent(ctx, res); err != nil {
125125 log.Ctx(ctx).Error().Err(err).Msg("failed to send event to tinybird")
126126 }
···141141 log.Ctx(ctx).Error().Err(err).Msg("failed to send event to tinybird")
142142 }
143143144144- // If the status was previously active, we update it to error.
145145- // Q: Why not always updating the status? My idea is that the checker should be dumb and only check the status and return it.
146144 if req.Status == "active" {
147145 checker.UpdateStatus(ctx, checker.UpdateData{
148146 MonitorId: req.MonitorID,
···151149 Region: flyRegion,
152150 })
153151 }
152152+154153 }
155154156155 c.JSON(http.StatusOK, gin.H{"message": "ok"})