mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-13 07:27:43 +00:00
add logging for things
This commit is contained in:
parent
5ede5d6987
commit
47a0aa47dd
2 changed files with 19 additions and 2 deletions
|
@ -335,6 +335,17 @@ func (sc *subredditsConsumer) Consume(delivery rmq.Delivery) {
|
|||
continue
|
||||
}
|
||||
|
||||
sc.logger.Info("matched post",
|
||||
zap.Int64("subreddit#id", id),
|
||||
zap.String("subreddit#name", subreddit.NormalizedName()),
|
||||
zap.Int64("watcher#id", watcher.ID),
|
||||
zap.String("watcher#keywords", watcher.Keyword),
|
||||
zap.Int64("watcher#upvotes", watcher.Upvotes),
|
||||
zap.String("post#id", post.ID),
|
||||
zap.String("post#title", post.Title),
|
||||
zap.Int64("post#score", post.Score),
|
||||
)
|
||||
|
||||
lockKey := fmt.Sprintf("watcher:%d:%s", watcher.DeviceID, post.ID)
|
||||
notified, _ := sc.redis.Get(sc, lockKey).Bool()
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ func (tc *trendingConsumer) Consume(delivery rmq.Delivery) {
|
|||
|
||||
tps, err := rac.SubredditTop(tc, subreddit.Name, reddit.WithQuery("t", "week"))
|
||||
if err != nil {
|
||||
tc.logger.Error("failed to fetch month's top posts",
|
||||
tc.logger.Error("failed to fetch weeks's top posts",
|
||||
zap.Error(err),
|
||||
zap.Int64("subreddit#id", id),
|
||||
zap.String("subreddit#name", subreddit.NormalizedName()),
|
||||
|
@ -182,7 +182,7 @@ func (tc *trendingConsumer) Consume(delivery rmq.Delivery) {
|
|||
return
|
||||
}
|
||||
|
||||
tc.logger.Debug("loaded month's top posts",
|
||||
tc.logger.Debug("loaded weeks's top posts",
|
||||
zap.Int64("subreddit#id", id),
|
||||
zap.String("subreddit#name", subreddit.NormalizedName()),
|
||||
zap.Int("count", tps.Count),
|
||||
|
@ -205,11 +205,17 @@ func (tc *trendingConsumer) Consume(delivery rmq.Delivery) {
|
|||
return
|
||||
}
|
||||
|
||||
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.Strings("subreddit#posts", posts),
|
||||
zap.Int64("score", medianScore),
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue