Add room range

This commit is contained in:
Leonardo Segala 2025-08-02 01:14:58 +02:00
parent 4a3c75cd51
commit 0d659beffb
2 changed files with 8 additions and 1 deletions

View file

@ -33,7 +33,8 @@ state.rooms[1000] = Room(
name="Test Room", name="Test Room",
pin=None, pin=None,
tags=set(), tags=set(),
songs={}, range_size=100,
songs={"b": (Song(uuid="b", title="title", artist="art", tags=["a", "B"], image_id="img", youtube_id="yt"), 1)},
history=[], history=[],
playing=[Song(uuid="<uuid>", title="<title>", artist="<artist>", tags=[], image_id="<img>", youtube_id="<yt>")], playing=[Song(uuid="<uuid>", title="<title>", artist="<artist>", tags=[], image_id="<img>", youtube_id="<yt>")],
playing_idx=0, playing_idx=0,
@ -114,6 +115,9 @@ def room_new():
if (room_cords := request.args.get("coords")) is None: if (room_cords := request.args.get("coords")) is None:
return error("Missing room coords") return error("Missing room coords")
if (room_range := request.args.get("range")) is None:
return error("Missing room range")
if room_pin := request.args.get("pin"): if room_pin := request.args.get("pin"):
room_pin = int(room_pin) room_pin = int(room_pin)
else: else:
@ -124,6 +128,7 @@ def room_new():
room = Room( room = Room(
id=max(state.rooms or [0]) + 1, # id=max(state.rooms or [0]) + 1, #
coord=(float(lat), float(lon)), coord=(float(lat), float(lon)),
range_size=int(room_range),
name=room_name, name=room_name,
pin=room_pin, pin=room_pin,
tags=set([tag for tag in request.args.get("tags", "").split(",") if tag]), tags=set([tag for tag in request.args.get("tags", "").split(",") if tag]),

View file

@ -34,6 +34,7 @@ class Room:
name: str name: str
pin: int | None pin: int | None
tags: set[str] tags: set[str]
range_size: int # in meters ??
songs: dict[str, UserScoredSong] # all songs + user score (the playlist) songs: dict[str, UserScoredSong] # all songs + user score (the playlist)
history: list[Song] # all songs previously played history: list[Song] # all songs previously played
@ -125,6 +126,7 @@ def test_algo():
"test", "test",
None, None,
set(["rock", "rap"]), set(["rock", "rap"]),
100,
{ {
"paulham": (songs[0], 7), "paulham": (songs[0], 7),
"cisco": (songs[1], 5), "cisco": (songs[1], 5),