Compare commits
3 Commits
e441a22fc8
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e0a596ffe3 | |||
| f98ed38a26 | |||
| c8342ee398 |
@@ -31,7 +31,9 @@ def write_event(event, game: str) -> bool:
|
||||
p = Point(event.type).time(event.time * 1_000_000_000)
|
||||
p.tag("game", game)
|
||||
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)
|
||||
write_api.write(bucket=INFLUX_BUCKET, record=p)
|
||||
return True
|
||||
|
||||
@@ -3,7 +3,7 @@ from fastapi.responses import JSONResponse, FileResponse
|
||||
from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
||||
from .auth import init_db, verify_api_key, get_db
|
||||
from .models import Event, BatchEvents
|
||||
from .influx import write_ev3t, client, INFLUX_ORG, INFLUX_BUCKET
|
||||
from .influx import write_event, client, INFLUX_ORG, INFLUX_BUCKET
|
||||
import logging
|
||||
import os
|
||||
import secrets
|
||||
@@ -36,11 +36,8 @@ async def ingest_event(payload: Event | BatchEvents, game: str = Depends(verify_
|
||||
def check_event(e: Event):
|
||||
if not e.type or not e.type.strip():
|
||||
raise HTTPException(400, "Event type is required")
|
||||
if not e.serverId:
|
||||
raise HTTPException(400, "serverId is required")
|
||||
if e.time <= 0:
|
||||
raise HTTPException(400, "Invalid timestamp")
|
||||
# Optionally refuse huge data (e.g., >1KB per event)
|
||||
|
||||
if isinstance(payload, BatchEvents):
|
||||
for event in payload.events:
|
||||
|
||||
Reference in New Issue
Block a user