diff --git a/api/chalicelib/core/click_maps.py b/api/chalicelib/core/click_maps.py index d62417e8f..d3a2b912b 100644 --- a/api/chalicelib/core/click_maps.py +++ b/api/chalicelib/core/click_maps.py @@ -51,7 +51,7 @@ def search_short_session(data: schemas.FlatClickMapSessionsSearch, project_id, u main_query = cur.mogrify(f"""SELECT {SESSION_PROJECTION_COLS} {"," if len(meta_keys) > 0 else ""}{",".join([f'metadata_{m["index"]}' for m in meta_keys])} {query_part} - ORDER BY {data.sort} {data.order} + ORDER BY {data.sort} {data.order.value} LIMIT 1;""", full_args) # print("--------------------") # print(main_query) diff --git a/api/chalicelib/core/custom_metrics.py b/api/chalicelib/core/custom_metrics.py index 2ff14004f..060227427 100644 --- a/api/chalicelib/core/custom_metrics.py +++ b/api/chalicelib/core/custom_metrics.py @@ -396,7 +396,7 @@ def search_all(project_id, user_id, data: schemas.SearchCardsSchema, include_ser AND users.user_id = metrics.user_id ) AS owner ON (TRUE) WHERE {" AND ".join(constraints)} - ORDER BY created_at {data.order} + ORDER BY created_at {data.order.value} LIMIT %(limit)s OFFSET %(offset)s;""", params) cur.execute(query) rows = cur.fetchall() diff --git a/api/chalicelib/core/sessions_notes.py b/api/chalicelib/core/sessions_notes.py index cc27b1931..d0f54bd96 100644 --- a/api/chalicelib/core/sessions_notes.py +++ b/api/chalicelib/core/sessions_notes.py @@ -69,7 +69,7 @@ def get_all_notes_by_project_id(tenant_id, project_id, user_id, data: schemas.Se query = cur.mogrify(f"""SELECT sessions_notes.* FROM sessions_notes WHERE {" AND ".join(conditions)} - ORDER BY created_at {data.order} + ORDER BY created_at {data.order.value} LIMIT {data.limit} OFFSET {data.limit * (data.page - 1)};""", {"project_id": project_id, "user_id": user_id, "tenant_id": tenant_id, **extra_params}) diff --git a/ee/api/chalicelib/core/assist_records.py b/ee/api/chalicelib/core/assist_records.py index 18449dc14..cda9419f6 100644 --- a/ee/api/chalicelib/core/assist_records.py +++ b/ee/api/chalicelib/core/assist_records.py @@ -61,7 +61,7 @@ def search_records(project_id, data: schemas_ee.AssistRecordSearchPayloadSchema, INNER JOIN projects USING (project_id) LEFT JOIN users USING (user_id) WHERE {" AND ".join(conditions)} - ORDER BY assist_records.created_at {data.order} + ORDER BY assist_records.created_at {data.order.value} LIMIT %(p_limit)s OFFSET %(p_start)s;""", params) cur.execute(query) diff --git a/ee/api/chalicelib/core/custom_metrics.py b/ee/api/chalicelib/core/custom_metrics.py index 5d4ea1c67..02a1607c2 100644 --- a/ee/api/chalicelib/core/custom_metrics.py +++ b/ee/api/chalicelib/core/custom_metrics.py @@ -427,7 +427,7 @@ def search_all(project_id, user_id, data: schemas.SearchCardsSchema, include_ser AND users.user_id = metrics.user_id ) AS owner ON (TRUE) WHERE {" AND ".join(constraints)} - ORDER BY created_at {data.order} + ORDER BY created_at {data.order.value} LIMIT %(limit)s OFFSET %(offset)s;""", params) cur.execute(query) rows = cur.fetchall() diff --git a/ee/api/chalicelib/core/sessions_notes.py b/ee/api/chalicelib/core/sessions_notes.py index 1a4a1704d..6f3ae1960 100644 --- a/ee/api/chalicelib/core/sessions_notes.py +++ b/ee/api/chalicelib/core/sessions_notes.py @@ -73,7 +73,7 @@ def get_all_notes_by_project_id(tenant_id, project_id, user_id, data: schemas.Se FROM sessions_notes INNER JOIN users USING (user_id) WHERE {" AND ".join(conditions)} - ORDER BY created_at {data.order} + ORDER BY created_at {data.order.value} LIMIT {data.limit} OFFSET {data.limit * (data.page - 1)};""", {"project_id": project_id, "user_id": user_id, "tenant_id": tenant_id, **extra_params}) diff --git a/ee/api/chalicelib/core/traces.py b/ee/api/chalicelib/core/traces.py index 14f26e0b6..52866cc99 100644 --- a/ee/api/chalicelib/core/traces.py +++ b/ee/api/chalicelib/core/traces.py @@ -179,10 +179,10 @@ def get_all(tenant_id, data: schemas_ee.TrailSearchPayloadSchema): COALESCE(JSONB_AGG(full_traces ORDER BY rn) FILTER (WHERE rn > %(p_start)s AND rn <= %(p_end)s), '[]'::JSONB) AS sessions FROM (SELECT traces.*,users.email,users.name AS username, - ROW_NUMBER() OVER (ORDER BY traces.created_at {data.order}) AS rn + ROW_NUMBER() OVER (ORDER BY traces.created_at {data.order.value}) AS rn FROM traces LEFT JOIN users USING (user_id) WHERE {" AND ".join(conditions)} - ORDER BY traces.created_at {data.order}) AS full_traces;""", params) + ORDER BY traces.created_at {data.order.value}) AS full_traces;""", params) ) rows = cur.fetchone() return helper.dict_to_camel_case(rows)