Replace websocket flow with SSE support in backend.
Update handlers, services, router, and data conversion logic to support server-sent events and related message pipeline changes. Made-with: Cursor
This commit is contained in:
@@ -177,7 +177,9 @@ func (r *UserRepository) RefreshFollowersCount(userID string) error {
|
||||
// GetPostsCount 获取用户帖子数(实时计算)
|
||||
func (r *UserRepository) GetPostsCount(userID string) (int64, error) {
|
||||
var count int64
|
||||
err := r.db.Model(&model.Post{}).Where("user_id = ?", userID).Count(&count).Error
|
||||
err := r.db.Model(&model.Post{}).
|
||||
Where("user_id = ? AND status = ?", userID, model.PostStatusPublished).
|
||||
Count(&count).Error
|
||||
return count, err
|
||||
}
|
||||
|
||||
@@ -202,7 +204,7 @@ func (r *UserRepository) GetPostsCountBatch(userIDs []string) (map[string]int64,
|
||||
var counts []CountResult
|
||||
err := r.db.Model(&model.Post{}).
|
||||
Select("user_id, count(*) as count").
|
||||
Where("user_id IN ?", userIDs).
|
||||
Where("user_id IN ? AND status = ?", userIDs, model.PostStatusPublished).
|
||||
Group("user_id").
|
||||
Scan(&counts).Error
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user