Files
VLoop/backend/internal/video/comment_store.go
huanghaosheng d782ccbb53 refactor(p0-5): 收敛热度相关注释
背景叙述与历史取舍已写进 `docs/design/hot-ranking.md`,从源码删除。
只保留不变式与安全约束:`clientFoundRows` 禁令、唯一索引判重、
成员补零的排序约定、快照用 `RENAMENX` 只建一次、`EXPIRE` 失败即删键。

`video_service.go` 的 `NewVideoService` 注释原本复述已删方法的来历,一并收敛。
`zset.go` 的 `ZUnionStore` 与 `RenameNX` 注释各压到四行以内。

验证:go build ./... 通过。
验证:go vet ./... 通过。
验证:go test -count=1 ./... 全绿(本机无 cgo,未跑 -race)。
验证:go test -tags integration -p 1 -count=1 ./internal/feed/ ./internal/video/ ./internal/worker/ 全绿。
2026-11-01 16:47:31 +08:00

39 lines
1.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package video
import (
"context"
)
// Mention 是一条待写入的提及通知。
type Mention struct {
RecipientID uint
SenderID uint
TargetID uint
Content string
DedupeKey string
}
type CommentStore interface {
// CreateIdempotentWithPopularity 同事务插入评论并给热度加 delta;
// created=false 表示该意图已落库,调用方不得再加热度。
CreateIdempotentWithPopularity(ctx context.Context, c *Comment, delta int64) (created bool, err error)
GetByID(ctx context.Context, id uint) (*Comment, error)
// DeleteWithPopularity 同事务删除评论并给热度 -1,返回被删的行。
DeleteWithPopularity(ctx context.Context, id uint) (row *Comment, deleted bool, err error)
GetAllComments(ctx context.Context, videoID uint) ([]Comment, error)
CreateMentions(ctx context.Context, mentions []Mention) error
FindAccountIDs(ctx context.Context, usernames []string) (map[string]uint, error)
}
// nilIfEmpty 供可空唯一列使用:空串会互撞,NULL 才是"没有这个键"。
func nilIfEmpty(s string) *string {
if s == "" {
return nil
}
return &s
}