more tweaks

This commit is contained in:
Andre Medeiros 2021-10-17 11:48:41 -04:00
parent b5bc51dfd7
commit 6f2c956082

View file

@ -165,16 +165,12 @@ func (snc *stuckNotificationsConsumer) Consume(delivery rmq.Delivery) {
}
}
lastAlertedAt := 0.0
if things.Count > 0 {
for _, thing := range things.Children {
if thing.FullName() != account.LastMessageID {
continue
}
lastAlertedAt = thing.CreatedAt
if !thing.IsDeleted() {
snc.logger.WithFields(logrus.Fields{
"account#username": account.NormalizedUsername(),
@ -191,6 +187,10 @@ func (snc *stuckNotificationsConsumer) Consume(delivery rmq.Delivery) {
}).Info("thing got deleted, resetting")
if kind != "t4" {
snc.logger.WithFields(logrus.Fields{
"account#username": account.NormalizedUsername(),
}).Info("getting message inbox to determine last good thing")
things, err = rac.MessageInbox()
if err != nil {
snc.logger.WithFields(logrus.Fields{
@ -202,19 +202,21 @@ func (snc *stuckNotificationsConsumer) Consume(delivery rmq.Delivery) {
}
account.LastMessageID = ""
snc.logger.WithFields(logrus.Fields{
"account#username": account.NormalizedUsername(),
}).Debug("calculating last good thing")
for _, thing := range things.Children {
if thing.IsDeleted() {
snc.logger.WithFields(logrus.Fields{
"account#username": account.NormalizedUsername(),
"thing#id": thing.FullName(),
}).Debug("thing deleted, next")
continue
}
if lastAlertedAt == 0 {
account.LastMessageID = thing.FullName()
break
}
if lastAlertedAt > thing.CreatedAt {
account.LastMessageID = thing.FullName()
}
account.LastMessageID = thing.FullName()
break
}
snc.logger.WithFields(logrus.Fields{