Peter Mutwiri commited on
Commit Β·
98c2088
1
Parent(s): 9efb816
added redis streams endpoint
Browse files- app/main.py +24 -0
app/main.py
CHANGED
|
@@ -305,6 +305,30 @@ async def continuous_kpi_refresh():
|
|
| 305 |
|
| 306 |
await asyncio.sleep(300) # 5 minutes
|
| 307 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
# βββ Root Endpoint βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 309 |
@app.get("/", tags=["root"])
|
| 310 |
def read_root():
|
|
|
|
| 305 |
|
| 306 |
await asyncio.sleep(300) # 5 minutes
|
| 307 |
|
| 308 |
+
|
| 309 |
+
@app.get("/debug/stream-content")
|
| 310 |
+
def debug_stream(
|
| 311 |
+
org_id: str = Query(...),
|
| 312 |
+
source_id: str = Query(...),
|
| 313 |
+
api_key: str = Depends(verify_api_key)
|
| 314 |
+
):
|
| 315 |
+
"""See what's actually in the Redis stream"""
|
| 316 |
+
stream_key = f"stream:analytics:{org_id}:{source_id}"
|
| 317 |
+
events = event_hub.read_recent_stream(stream_key, 10)
|
| 318 |
+
|
| 319 |
+
# Also check for entity/industry keys
|
| 320 |
+
entity_key = f"entity:{org_id}:{source_id}"
|
| 321 |
+
industry_key = f"industry:{org_id}:{source_id}"
|
| 322 |
+
|
| 323 |
+
return {
|
| 324 |
+
"stream_key": stream_key,
|
| 325 |
+
"events_count": len(events),
|
| 326 |
+
"events": events,
|
| 327 |
+
"entity_exists": bool(event_hub.get_key(entity_key)),
|
| 328 |
+
"industry_exists": bool(event_hub.get_key(industry_key)),
|
| 329 |
+
"entity_data": event_hub.get_key(entity_key),
|
| 330 |
+
"industry_data": event_hub.get_key(industry_key),
|
| 331 |
+
}
|
| 332 |
# βββ Root Endpoint βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 333 |
@app.get("/", tags=["root"])
|
| 334 |
def read_root():
|