Compare commits

...

5 Commits

Author SHA1 Message Date
e0a596ffe3 added custom tag support 2026-04-27 23:48:46 +02:00
f98ed38a26 fixed typo 2026-04-27 23:27:22 +02:00
c8342ee398 removed check for server id 2026-04-27 23:23:01 +02:00
e441a22fc8 removed server id fully 2026-04-27 23:18:21 +02:00
4822b83069 removed server id 2026-04-27 23:17:50 +02:00
3 changed files with 4 additions and 8 deletions

View File

@@ -30,10 +30,10 @@ def write_event(event, game: str) -> bool:
try: try:
p = Point(event.type).time(event.time * 1_000_000_000) p = Point(event.type).time(event.time * 1_000_000_000)
p.tag("game", game) p.tag("game", game)
p.tag("serverId", event.serverId)
# Ensure data is a dict, even if not provided
for k, v in (event.data or {}).items(): for k, v in (event.data or {}).items():
if isinstance(v, (int, float, str, bool)): if k.startswith("tag_"):
p.tag(k[4:], str(v))
elif isinstance(v, (int, float, str, bool)):
p.field(k, v) p.field(k, v)
write_api.write(bucket=INFLUX_BUCKET, record=p) write_api.write(bucket=INFLUX_BUCKET, record=p)
return True return True

View File

@@ -36,12 +36,9 @@ async def ingest_event(payload: Event | BatchEvents, game: str = Depends(verify_
def check_event(e: Event): def check_event(e: Event):
if not e.type or not e.type.strip(): if not e.type or not e.type.strip():
raise HTTPException(400, "Event type is required") raise HTTPException(400, "Event type is required")
if not e.serverId:
raise HTTPException(400, "serverId is required")
if e.time <= 0: if e.time <= 0:
raise HTTPException(400, "Invalid timestamp") raise HTTPException(400, "Invalid timestamp")
# Optionally refuse huge data (e.g., >1KB per event)
if isinstance(payload, BatchEvents): if isinstance(payload, BatchEvents):
for event in payload.events: for event in payload.events:
write_event(event, game) write_event(event, game)

View File

@@ -4,7 +4,6 @@ from typing import Any, List, Optional
class Event(BaseModel): class Event(BaseModel):
type: str type: str
time: int time: int
serverId: str
data: Optional[dict] = {} data: Optional[dict] = {}
class BatchEvents(BaseModel): class BatchEvents(BaseModel):