refactor(lio): use REALTIME for multiplayer room
This commit is contained in:
@@ -17,7 +17,7 @@ from app.dependencies.storage import get_storage_service
|
|||||||
from app.fetcher import Fetcher
|
from app.fetcher import Fetcher
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.models.multiplayer_hub import PlaylistItem as HubPlaylistItem
|
from app.models.multiplayer_hub import PlaylistItem as HubPlaylistItem
|
||||||
from app.models.room import MatchType, QueueMode, RoomStatus
|
from app.models.room import MatchType, QueueMode, RoomCategory, RoomStatus
|
||||||
from app.storage.base import StorageService
|
from app.storage.base import StorageService
|
||||||
from app.utils import utcnow
|
from app.utils import utcnow
|
||||||
|
|
||||||
@@ -177,6 +177,7 @@ async def _create_room(db: Database, room_data: dict[str, Any]) -> tuple[Room, i
|
|||||||
# 创建房间
|
# 创建房间
|
||||||
room = Room(
|
room = Room(
|
||||||
name=room_name,
|
name=room_name,
|
||||||
|
category=RoomCategory.REALTIME,
|
||||||
host_id=host_user_id,
|
host_id=host_user_id,
|
||||||
password=password if password else None,
|
password=password if password else None,
|
||||||
type=match_type_enum,
|
type=match_type_enum,
|
||||||
|
|||||||
@@ -50,11 +50,7 @@ async def get_all_rooms(
|
|||||||
current_user: User = Security(get_current_user, scopes=["public"]),
|
current_user: User = Security(get_current_user, scopes=["public"]),
|
||||||
):
|
):
|
||||||
resp_list: list[RoomResp] = []
|
resp_list: list[RoomResp] = []
|
||||||
if category == RoomCategory.REALTIME:
|
where_clauses: list[ColumnElement[bool]] = [col(Room.category) == category]
|
||||||
db_category = RoomCategory.NORMAL # 实际查询 normal
|
|
||||||
else:
|
|
||||||
db_category = category
|
|
||||||
where_clauses: list[ColumnElement[bool]] = [col(Room.category) == db_category]
|
|
||||||
now = utcnow()
|
now = utcnow()
|
||||||
|
|
||||||
if status is not None:
|
if status is not None:
|
||||||
@@ -95,7 +91,6 @@ async def get_all_rooms(
|
|||||||
)
|
)
|
||||||
for room in db_rooms:
|
for room in db_rooms:
|
||||||
resp = await RoomResp.from_db(room, db)
|
resp = await RoomResp.from_db(room, db)
|
||||||
resp.has_password = bool((room.password or "").strip())
|
|
||||||
if category == RoomCategory.REALTIME:
|
if category == RoomCategory.REALTIME:
|
||||||
resp.category = RoomCategory.NORMAL
|
resp.category = RoomCategory.NORMAL
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user