From 04644520889c36f19d326c7e791b7519ce4ed2e7 Mon Sep 17 00:00:00 2001 From: Umputun Date: Fri, 29 Dec 2017 00:17:28 -0600 Subject: [PATCH] debug info to importer --- app/migrator/disqus.go | 6 ++++-- app/rest/auth/middleware.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/migrator/disqus.go b/app/migrator/disqus.go index 0fb1d817..fe63910f 100644 --- a/app/migrator/disqus.go +++ b/app/migrator/disqus.go @@ -76,7 +76,7 @@ func (d *Disqus) convert(r io.Reader, siteID string) (ch chan store.Comment) { inpThreads, inpComments := 0, 0 go func() { - commentsCount := 0 + commentsCount, spamComments := 0, 0 for { t, err := decoder.Token() if t == nil || err != nil { @@ -100,6 +100,7 @@ func (d *Disqus) convert(r io.Reader, siteID string) (ch chan store.Comment) { continue } if comment.IsSpam { + spamComments++ continue } c := store.Comment{ @@ -126,7 +127,8 @@ func (d *Disqus) convert(r io.Reader, siteID string) (ch chan store.Comment) { } } close(commentsCh) - log.Printf("[INFO] converted %d posts with %d comments from disqus %d/%d", len(postsMap), commentsCount, inpThreads, inpComments) + log.Printf("[INFO] converted %d posts with %d comments from disqus %d/%d, spam %d", + len(postsMap), commentsCount, inpThreads, inpComments, spamComments) }() return commentsCh diff --git a/app/rest/auth/middleware.go b/app/rest/auth/middleware.go index b0a0cede..68e7abb7 100644 --- a/app/rest/auth/middleware.go +++ b/app/rest/auth/middleware.go @@ -117,7 +117,7 @@ func GetUserInfo(r *http.Request) (user store.User, err error) { ctx := r.Context() if ctx == nil { - return store.User{}, errors.New("user not defined") + return store.User{}, errors.New("no info about user") } if u, ok := ctx.Value(contextKey("user")).(store.User); ok {