Fix: entry token 만료 기반으로 stale waiting room 판단
타임아웃 대신 Redis entry token 존재 여부로 판단: - pending token이 Redis에 남아있음 → 정상 로딩 중, 방 보존 - pending token이 없음 (만료/소비) → abandoned 확정, 즉시 정리 정상 로딩 중인 파티원의 방을 보호하면서도 강제 종료 유저의 즉각적 복구 가능. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -64,14 +64,13 @@ func (r *Repository) CountActiveByUsername(username string) (int64, error) {
|
||||
return count, err
|
||||
}
|
||||
|
||||
// FindStaleWaitingRoomsByUsername returns waiting rooms containing the given username
|
||||
// that were created before the threshold.
|
||||
func (r *Repository) FindStaleWaitingRoomsByUsername(username string, threshold time.Time) ([]BossRoom, error) {
|
||||
// FindWaitingRoomsByUsername returns all waiting rooms containing the given username.
|
||||
func (r *Repository) FindWaitingRoomsByUsername(username string) ([]BossRoom, error) {
|
||||
escaped := strings.NewReplacer("%", "\\%", "_", "\\_").Replace(username)
|
||||
search := `"` + escaped + `"`
|
||||
var rooms []BossRoom
|
||||
err := r.db.Where("status = ? AND players LIKE ? AND created_at < ?",
|
||||
StatusWaiting, "%"+search+"%", threshold).
|
||||
err := r.db.Where("status = ? AND players LIKE ?",
|
||||
StatusWaiting, "%"+search+"%").
|
||||
Find(&rooms).Error
|
||||
return rooms, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user