Skip to content

Commit

Permalink
report_count廃止
Browse files Browse the repository at this point in the history
  • Loading branch information
tukeJonny committed Oct 31, 2023
1 parent 8f85800 commit 3744c7d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 35 deletions.
1 change: 1 addition & 0 deletions bench/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/urfave/cli v1.22.1
go.uber.org/zap v1.26.0
golang.org/x/sync v0.4.0

)

require (
Expand Down
1 change: 0 additions & 1 deletion bench/isupipe/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func assertSearchLivestream() {
// FIXME: いくらか画面表示内容に問題がないことをチェックする

// moderateにより登録されたNGワードが含まれるコメントが残っていたら失格
// FIXME: ベンチ側では、ngワードのmoderate後に含まれる投稿を見つけたら失格扱いにする
func assertModeratedComment() {
// NGワード一覧取得

Expand Down
17 changes: 9 additions & 8 deletions bench/isupipe/client_livecomment.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import (
)

type Livecomment struct {
Id int `json:"id"`
User User `json:"user"`
Livestream Livestream `json:"livestream"`
Comment string `json:"comment"`
Tip int `json:"tip"`
ReportCount int `json:"report_count"`
CreatedAt int `json:"created_at"`
UpdatedAt int `json:"updated_at"`
Id int `json:"id"`
User User `json:"user"`
Livestream Livestream `json:"livestream"`
Comment string `json:"comment"`
Tip int `json:"tip"`
CreatedAt int `json:"created_at"`
UpdatedAt int `json:"updated_at"`
}

type LivecommentReport struct {
Expand Down Expand Up @@ -123,6 +122,8 @@ func (c *Client) GetLivecommentReports(ctx context.Context, livestreamId int, op
return reports, nil
}

func (c *Client) GetNgwords(ctx context.Context)

func (c *Client) PostLivecomment(ctx context.Context, livestreamId int, r *PostLivecommentRequest, opts ...ClientOption) (*PostLivecommentResponse, error) {
var (
defaultStatusCode = http.StatusCreated
Expand Down
2 changes: 0 additions & 2 deletions docs/isupipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,6 @@ components:
type: string
tip:
type: integer
report_count:
type: integer
created_at:
type: integer
updated_at:
Expand Down
35 changes: 14 additions & 21 deletions webapp/go/livecomment_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,18 @@ type LivecommentModel struct {
LivestreamId int64 `db:"livestream_id"`
Comment string `db:"comment"`
Tip int64 `db:"tip"`
ReportCount int64 `db:"report_count"`
CreatedAt int64 `db:"created_at"`
UpdatedAt int64 `db:"updated_at"`
}

type Livecomment struct {
Id int64 `json:"id"`
User User `json:"user"`
Livestream Livestream `json:"livestream"`
Comment string `json:"comment"`
Tip int64 `json:"tip"`
ReportCount int64 `json:"report_count"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
Id int64 `json:"id"`
User User `json:"user"`
Livestream Livestream `json:"livestream"`
Comment string `json:"comment"`
Tip int64 `json:"tip"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}

type LivecommentReport struct {
Expand Down Expand Up @@ -334,10 +332,6 @@ func reportLivecommentHandler(c echo.Context) error {
}
reportModel.Id = reportId

if _, err := tx.ExecContext(ctx, "UPDATE livecomments SET report_count = report_count + 1 WHERE id = ?", livecommentId); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}

report, err := fillLivecommentReportResponse(ctx, tx, reportModel)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
Expand Down Expand Up @@ -435,14 +429,13 @@ func fillLivecommentResponse(ctx context.Context, tx *sqlx.Tx, livecommentModel
}

livecomment := Livecomment{
Id: livecommentModel.Id,
User: commentOwner,
Livestream: livestream,
Comment: livecommentModel.Comment,
Tip: livecommentModel.Tip,
ReportCount: livecommentModel.ReportCount,
CreatedAt: livecommentModel.CreatedAt,
UpdatedAt: livecommentModel.UpdatedAt,
Id: livecommentModel.Id,
User: commentOwner,
Livestream: livestream,
Comment: livecommentModel.Comment,
Tip: livecommentModel.Tip,
CreatedAt: livecommentModel.CreatedAt,
UpdatedAt: livecommentModel.UpdatedAt,
}

return livecomment, nil
Expand Down
4 changes: 1 addition & 3 deletions webapp/sql/initdb.d/10_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,11 @@ CREATE TABLE `livecomments` (
-- 単位はISU (1,2,3,4,5, ...などわかりやすい数値で良い気がする)
-- 色は、青、水、黄緑、黃、マゼンタ、赤の6段階 (ココらへんはフロントエンドでいい感じにしてもらう)
`tip` BIGINT NOT NULL,
-- スパム報告数
`report_count` BIGINT DEFAULT 0 NOT NULL,
`created_at` BIGINT NOT NULL DEFAULT 0,
`updated_at` BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE INDEX livecomments_covering ON livecomments(`created_at`, `user_id`, `tip`, `report_count`, `updated_at`, `comment`, `livestream_id`);
CREATE INDEX livecomments_covering ON livecomments(`created_at`, `user_id`, `tip`, `updated_at`, `comment`, `livestream_id`);

-- ユーザからのライブコメントのスパム報告
CREATE TABLE `livecomment_reports` (
Expand Down

0 comments on commit 3744c7d

Please sign in to comment.