模拟飘屏修复
This commit is contained in:
parent
9aecdf34a3
commit
5b92fef113
@ -199,7 +199,7 @@ func (w *BroadcastSimulationWorker) run(ctx context.Context, req ContinuousSimul
|
||||
|
||||
func (w *BroadcastSimulationWorker) runOnce(ctx context.Context, req ContinuousSimulationRequest, rng *rand.Rand) {
|
||||
regionCode := req.RegionCodes[rng.Intn(len(req.RegionCodes))]
|
||||
userID, err := w.randomOfflineUser(ctx, req.SysOrigin, regionCode, rng)
|
||||
userID, err := w.randomOfflineUser(ctx, req.SysOrigin, rng)
|
||||
if err != nil {
|
||||
w.setLastError(err)
|
||||
return
|
||||
@ -332,14 +332,12 @@ func (w *BroadcastSimulationWorker) sendContinuous(ctx context.Context, req Broa
|
||||
return err
|
||||
}
|
||||
|
||||
func (w *BroadcastSimulationWorker) randomOfflineUser(ctx context.Context, sysOrigin string, regionCode string, rng *rand.Rand) (int64, error) {
|
||||
func (w *BroadcastSimulationWorker) randomOfflineUser(ctx context.Context, sysOrigin string, rng *rand.Rand) (int64, error) {
|
||||
onlineIDs := w.onlineUserIDs(ctx, sysOrigin)
|
||||
query := w.db.WithContext(ctx).
|
||||
Table("user_base_info AS user").
|
||||
Select("user.id AS id").
|
||||
Joins("LEFT JOIN voice_room_region_country AS region ON region.sys_origin = ? AND region.country_code = user.country_code AND region.enabled = ?", sysOrigin, true).
|
||||
Where("user.origin_sys = ?", sysOrigin).
|
||||
Where("(region.region_code = ? OR user.country_code = ?)", regionCode, regionCode).
|
||||
Where("user.id > 0")
|
||||
if len(onlineIDs) > 0 && len(onlineIDs) <= 1000 {
|
||||
query = query.Where("user.id NOT IN ?", onlineIDs)
|
||||
@ -363,7 +361,7 @@ func (w *BroadcastSimulationWorker) randomOfflineUser(ctx context.Context, sysOr
|
||||
filtered = append(filtered, user)
|
||||
}
|
||||
if len(filtered) == 0 {
|
||||
return 0, common.NewAppError(http.StatusNotFound, "simulation_offline_user_not_found", "offline user not found for selected region")
|
||||
return 0, common.NewAppError(http.StatusNotFound, "simulation_offline_user_not_found", "offline user not found")
|
||||
}
|
||||
return filtered[rng.Intn(len(filtered))].ID, nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user