Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikus1993 committed Feb 13, 2022
1 parent f7401ab commit e1ee97d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func createDiscordEmbedsFromArticles(articles []model.Article) []*discordgo.Mess
}

func (not *DiscordWebhookNotifier) Notify(ctx context.Context, articles []model.Article) error {
log.Infoln("Notifying via discord")
msg := discordgo.WebhookParams{Content: "Witam serdecznie, oto nowe newsy", Embeds: createDiscordEmbedsFromArticles(articles)}
_, err := not.client.WebhookExecute(not.webhookID, not.webhookToken, true, &msg)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/usecase/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ func (u *ParseArticlesAndSendItUseCase) Execute(ctx context.Context, articlesQua
if err != nil {
return err
}
log.Infoln("Found articles:", len(articles))
validArticles := u.filterValid(ctx, articles)
log.Infoln("Found valid articles:", len(validArticles))
newArticles := u.filterNewArticles(ctx, validArticles)
log.Infoln("Found new articles:", len(newArticles))
randomArticles := model.TakeRandomArticles(newArticles, articlesQuantity)
err = u.broadcaster.Broadcast(ctx, randomArticles)
if err != nil {
Expand Down

0 comments on commit e1ee97d

Please sign in to comment.