From f0353399e82b3244cb87c0ba87705dd6c6545ffb Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Fri, 27 May 2022 09:22:04 -0400 Subject: [PATCH] Revert "Don't log post titles anymore" This reverts commit e9a2f5b7450ebe89e780dcefb6cc145e7e52f0e9. --- internal/worker/trending.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/worker/trending.go b/internal/worker/trending.go index a1109a5..3533cea 100644 --- a/internal/worker/trending.go +++ b/internal/worker/trending.go @@ -7,6 +7,7 @@ import ( "os" "sort" "strconv" + "strings" "time" "github.com/DataDog/datadog-go/statsd" @@ -210,11 +211,17 @@ func (tc *trendingConsumer) Consume(delivery rmq.Delivery) { return tps.Children[i].Score > tps.Children[j].Score }) + posts := make([]string, tps.Count) + for i, post := range tps.Children { + posts[i] = fmt.Sprintf("%s: %d", post.Title, post.Score) + } + middlePost := tps.Count / 2 medianScore := tps.Children[middlePost].Score tc.logger.Info("calculated median score", zap.Int64("subreddit#id", id), zap.String("subreddit#name", subreddit.NormalizedName()), + zap.String("subreddit#posts", strings.Join(posts, "\n")), zap.Int64("score", medianScore), )