openreplay/api/chalicelib/core/resources.py
Taha Yassine Kraiem 714b8972ad feat(api): call to assist handles disconnection
feat(api): resources return status code
2022-03-18 14:46:23 +01:00

23 lines
828 B
Python

from chalicelib.utils import helper, pg_client
def get_by_session_id(session_id):
with pg_client.PostgresClient() as cur:
ch_query = """\
SELECT
timestamp AS datetime,
url,
type,
duration,
ttfb,
header_size,
encoded_body_size,
decoded_body_size,
success,
COALESCE(status, CASE WHEN success THEN 200 END) AS status
FROM events.resources
WHERE session_id = %(session_id)s;"""
params = {"session_id": session_id}
cur.execute(cur.mogrify(ch_query, params))
rows = cur.fetchall()
return helper.list_to_camel_case(rows)