be more forgiving with comment age

This commit is contained in:
Andre Medeiros 2022-10-26 19:31:16 -04:00
parent cd8b0b0dca
commit 9154ee8e7f

View file

@ -227,13 +227,24 @@ func (lac *liveActivitiesConsumer) Consume(delivery rmq.Delivery) {
// Filter out comments in the last minute
candidates := make([]*reddit.Thing, 0)
cutoff := now.Add(-domain.LiveActivityCheckInterval)
cutoffs := []time.Time{
now.Add(-domain.LiveActivityCheckInterval),
now.Add(-domain.LiveActivityCheckInterval * 2),
now.Add(-domain.LiveActivityCheckInterval * 4),
}
for _, cutoff := range cutoffs {
for _, t := range tr.Children {
if t.CreatedAt.After(cutoff) {
candidates = append(candidates, t)
}
}
if len(candidates) > 0 {
break
}
}
if len(candidates) == 0 {
lac.logger.Debug("no new comments found", zap.String("live_activity#apns_token", at))
return