From ada757c6f56fe22860f23d1fc41873cc87d33eab Mon Sep 17 00:00:00 2001 From: tukeJonny Date: Wed, 1 Nov 2023 13:03:06 +0900 Subject: [PATCH] debug --- webapp/go/stats_handler.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/webapp/go/stats_handler.go b/webapp/go/stats_handler.go index 0f2f49e86..db336b16e 100644 --- a/webapp/go/stats_handler.go +++ b/webapp/go/stats_handler.go @@ -1,6 +1,7 @@ package main import ( + "log" "net/http" "sort" "strconv" @@ -202,21 +203,25 @@ func getLivestreamStatisticsHandler(c echo.Context) error { } defer tx.Rollback() + log.Println("checkpoint1") var livestreams []*LivestreamModel if err := tx.SelectContext(ctx, &livestreams, "SELECT * FROM livestreams"); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } // ランク算出 + log.Println("checkpoint2") var ranking LivestreamRanking for _, livestream := range livestreams { var reactions int64 if err := tx.GetContext(ctx, &reactions, "SELECT COUNT(*) FROM livestreams l INNER JOIN reactions r ON l.id = r.livestream_id WHERE l.id = ?", livestreamID); err != nil { + log.Println("failed to get reaction count for livestream stats") return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } var totalTips int64 if err := tx.GetContext(ctx, &totalTips, "SELECT SUM(l2.tip) FROM livestreams l INNER JOIN livecomments l2 ON l.id = l2.livestream_id WHERE l.id = ?", livestreamID); err != nil { + log.Println("failed to get total tips for livestream stats") return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } @@ -238,30 +243,35 @@ func getLivestreamStatisticsHandler(c echo.Context) error { rank++ } + log.Println("checkpoint3") var livestream *LivestreamModel if err := tx.GetContext(ctx, &livestream, "SELECT * FROM livestreams WHERE id = ?", livestreamID); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } // 視聴者数算出 + log.Println("checkpoint4") var viewersCount int64 if err := tx.GetContext(ctx, &viewersCount, `SELECT COUNT(*) FROM livestreams l INNER JOIN livestream_viewers_history h ON h.livestream_id = l.id WHERE l.id = ?`, livestreamID); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } // 最大チップ額 + log.Println("checkpoint5") var maxTip int64 if err := tx.GetContext(ctx, &maxTip, `SELECT MAX(tip) FROM livestreams l INNER JOIN livecomments l2 ON l2.livestream_id = l.id WHERE l.id = ?`, livestreamID); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } // リアクション数 + log.Println("checkpoint6") var totalReactions int64 if err := tx.GetContext(ctx, &totalReactions, "SELECT COUNT(*) FROM livestreams l INNER JOIN reactions r ON r.livestream_id = l.id WHERE l.id = ?", livestreamID); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } // スパム報告数 + log.Println("checkpoint7") var totalReports int64 if err := tx.GetContext(ctx, &totalReports, `SELECT COUNT(*) FROM livestreams l INNER JOIN livecomment_reports r ON r.livestream_id = l.id WHERE l.id = ?`, livestreamID); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error())