fix(P1): Router Bug 修复 + Video 复合索引 + ListByAuthorID 加 LIMIT
This commit is contained in:
@@ -144,7 +144,7 @@ func SetRouter(db *gorm.DB, cache *rediscache.Client, rmq *rabbitmq.RabbitMQ) *g
|
|||||||
timelineMQ, err := rabbitmq.NewTimelineMQ(rmq)
|
timelineMQ, err := rabbitmq.NewTimelineMQ(rmq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("timelineMQ init failed (mq disabled): %v", err)
|
log.Printf("timelineMQ init failed (mq disabled): %v", err)
|
||||||
socialMQ = nil
|
timelineMQ = nil
|
||||||
}
|
}
|
||||||
worker.StartOutboxPoller(db, timelineMQ)
|
worker.StartOutboxPoller(db, timelineMQ)
|
||||||
worker.StartConsumer(timelineMQ, "video.timeline.update.queue", cache)
|
worker.StartConsumer(timelineMQ, "video.timeline.update.queue", cache)
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ type Video struct {
|
|||||||
Description string `gorm:"type:varchar(255);" json:"description,omitempty"`
|
Description string `gorm:"type:varchar(255);" json:"description,omitempty"`
|
||||||
PlayURL string `gorm:"type:varchar(255);not null" json:"play_url"`
|
PlayURL string `gorm:"type:varchar(255);not null" json:"play_url"`
|
||||||
CoverURL string `gorm:"type:varchar(255);not null" json:"cover_url"`
|
CoverURL string `gorm:"type:varchar(255);not null" json:"cover_url"`
|
||||||
CreateTime time.Time `gorm:"autoCreateTime" json:"create_time"`
|
CreateTime time.Time `gorm:"autoCreateTime;index:idx_videos_create_time,sort:desc;index:idx_videos_popularity_time_id,priority:2,sort:desc" json:"create_time"`
|
||||||
LikesCount int64 `gorm:"column:likes_count;not null;default:0" json:"likes_count"`
|
LikesCount int64 `gorm:"column:likes_count;not null;default:0;index:idx_videos_likes_count_id,priority:1,sort:desc" json:"likes_count"`
|
||||||
Popularity int64 `gorm:"column:popularity;not null;default:0" json:"popularity"`
|
Popularity int64 `gorm:"column:popularity;not null;default:0;index:idx_videos_popularity_time_id,priority:1,sort:desc" json:"popularity"`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type PublishVideoRequest struct {
|
type PublishVideoRequest struct {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func (vr *VideoRepository) ListByAuthorID(ctx context.Context, authorID int64) (
|
|||||||
if err := vr.db.WithContext(ctx).
|
if err := vr.db.WithContext(ctx).
|
||||||
Where("author_id = ?", authorID).
|
Where("author_id = ?", authorID).
|
||||||
Order("create_time desc").
|
Order("create_time desc").
|
||||||
Offset(0).
|
Limit(200).
|
||||||
Find(&videos).Error; err != nil {
|
Find(&videos).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user