Skip to content

Commit

Permalink
統計情報修正
Browse files Browse the repository at this point in the history
  • Loading branch information
tukeJonny committed Nov 1, 2023
1 parent 305e47c commit 6163bf4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions webapp/go/stats_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,29 @@ func getUserStatisticsHandler(c echo.Context) error {
// 配信を区別せず、すべての合計を取る必要がある

// ランク算出
// ユーザ一覧取得
var users []*UserModel
if err := tx.GetContext(ctx, &users, "SELECT * FROM users"); err != nil {
if err := tx.SelectContext(ctx, &users, "SELECT * FROM users"); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}

var ranking UserRanking
for _, user := range users {
var reactions int64
query := `
SELECT
`
if err := tx.GetContext(ctx, &reactions, query); err != nil {
SELECT COUNT(*) FROM users u
INNER JOIN livestreams l ON l.user_id = u.id
INNER JOIN reactions r ON r.livestream_id = l.id
WHERE u.id = ?`
if err := tx.GetContext(ctx, &reactions, query, user.ID); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}

var tips int64
query = `
`
SELECT SUM(l2.tip) FROM users u
INNER JOIN livestreams l ON l.user_id = u.id
INNER JOIN livecomments l2 ON l2.livestream_id = l.id
WHERE u.id = ?`
if err := tx.GetContext(ctx, &tips, query); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
Expand All @@ -121,9 +124,6 @@ func getUserStatisticsHandler(c echo.Context) error {
rank++
}

// 各ユーザについて、配信毎の各指標を取得し、スコア算出
// sort.Sortでソート

// リアクション数
var totalReactions int64
query := `SELECT COUNT(*) FROM users u
Expand Down

0 comments on commit 6163bf4

Please sign in to comment.