feat(api): get live sessions directly from websocket
This commit is contained in:
parent
5f70ab3778
commit
2fa444a26c
4 changed files with 19 additions and 10 deletions
|
|
@ -28,8 +28,8 @@ jwt_algorithm=HS512
|
|||
jwt_exp_delta_seconds=2592000
|
||||
jwt_issuer=openreplay-default-foss
|
||||
jwt_secret="SET A RANDOM STRING HERE"
|
||||
Opeers=http://utilities-openreplay.app.svc.cluster.local:9000/assist/%s/peers
|
||||
peers=http://utilities-openreplay.app.svc.cluster.local:9000/assist/%s/sockets-list
|
||||
Opeers=http://utilities-openreplay.app.svc.cluster.local:9000/assist/%s/sockets-list
|
||||
peers=http://utilities-openreplay.app.svc.cluster.local:9001/assist/%s/sockets-live
|
||||
pg_dbname=postgres
|
||||
pg_host=postgresql.db.svc.cluster.local
|
||||
pg_password=asayerPostgres
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import schemas
|
||||
from chalicelib.utils import pg_client, helper
|
||||
from chalicelib.core import projects, sessions, sessions_metas
|
||||
import requests
|
||||
from decouple import config
|
||||
|
||||
from chalicelib.core import projects, sessions, sessions_metas
|
||||
import schemas
|
||||
from chalicelib.core import projects, sessions
|
||||
from chalicelib.utils import pg_client, helper
|
||||
|
||||
SESSION_PROJECTION_COLS = """s.project_id,
|
||||
|
|
@ -66,6 +64,17 @@ def get_live_sessions(project_id, filters=None):
|
|||
return helper.list_to_camel_case(results)
|
||||
|
||||
|
||||
def get_live_sessions_ws(project_id):
|
||||
project_key = projects.get_project_key(project_id)
|
||||
connected_peers = requests.get(config("peers") % config("S3_KEY") + f"/{project_key}")
|
||||
if connected_peers.status_code != 200:
|
||||
print("!! issue with the peer-server")
|
||||
print(connected_peers.text)
|
||||
return []
|
||||
live_peers = connected_peers.json().get("data", [])
|
||||
return {"data": live_peers}
|
||||
|
||||
|
||||
def is_live(project_id, session_id, project_key=None):
|
||||
if project_key is None:
|
||||
project_key = projects.get_project_key(project_id)
|
||||
|
|
|
|||
|
|
@ -830,14 +830,14 @@ def all_issue_types(context: schemas.CurrentContext = Depends(OR_context)):
|
|||
|
||||
@app.get('/{projectId}/assist/sessions', tags=["assist"])
|
||||
def sessions_live(projectId: int, context: schemas.CurrentContext = Depends(OR_context)):
|
||||
data = assist.get_live_sessions(projectId)
|
||||
data = assist.get_live_sessions_ws(projectId)
|
||||
return {'data': data}
|
||||
|
||||
|
||||
@app.post('/{projectId}/assist/sessions', tags=["assist"])
|
||||
def sessions_live_search(projectId: int, data: schemas.AssistSearchPayloadSchema = Body(...),
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
data = assist.get_live_sessions(projectId, filters=data.filters)
|
||||
data = assist.get_live_sessions_ws(projectId)
|
||||
return {'data': data}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ jwt_algorithm=HS512
|
|||
jwt_exp_delta_seconds=2592000
|
||||
jwt_issuer=openreplay-default-ee
|
||||
jwt_secret="SET A RANDOM STRING HERE"
|
||||
Opeers=http://utilities-openreplay.app.svc.cluster.local:9000/assist/%s/peers
|
||||
peers=http://utilities-openreplay.app.svc.cluster.local:9000/assist/%s/sockets-list
|
||||
Opeers=http://utilities-openreplay.app.svc.cluster.local:9000/assist/%s/sockets-list
|
||||
peers=http://utilities-openreplay.app.svc.cluster.local:9001/assist/%s/sockets-live
|
||||
pg_dbname=postgres
|
||||
pg_host=postgresql.db.svc.cluster.local
|
||||
pg_password=asayerPostgres
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue