update last checked at

This commit is contained in:
Andre Medeiros 2021-07-08 20:33:35 -04:00
parent aad2434d83
commit f956033e2d

View file

@ -287,11 +287,6 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
"count": len(msgs.MessageListing.Messages), "count": len(msgs.MessageListing.Messages),
}).Debug("fetched messages") }).Debug("fetched messages")
if len(msgs.MessageListing.Messages) == 0 {
c.logger.WithFields(logrus.Fields{
"accountID": id,
}).Debug("no new messages, bailing early")
if err = c.pool.BeginFunc(ctx, func(tx pgx.Tx) error { if err = c.pool.BeginFunc(ctx, func(tx pgx.Tx) error {
stmt := ` stmt := `
UPDATE accounts UPDATE accounts
@ -306,9 +301,15 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
}).Error("failed to update last_checked_at for account") }).Error("failed to update last_checked_at for account")
delivery.Reject() delivery.Reject()
} else { return
delivery.Ack()
} }
if len(msgs.MessageListing.Messages) == 0 {
c.logger.WithFields(logrus.Fields{
"accountID": id,
}).Debug("no new messages, bailing early")
delivery.Ack()
return return
} }