diff --git a/api/chalicelib/core/metadata.py b/api/chalicelib/core/metadata.py index 9469903d0..1e7fcea00 100644 --- a/api/chalicelib/core/metadata.py +++ b/api/chalicelib/core/metadata.py @@ -259,7 +259,7 @@ def get_for_filters(project_id): results.append({"id": f"meta_{i}", "name": k, "displayName": metas[k], - "type": "string", + "possibleTypes": ["String"], "autoCaptured": False, "icon": None}) return {"total": len(results), "list": results} diff --git a/api/chalicelib/core/product_analytics/events.py b/api/chalicelib/core/product_analytics/events.py index 5b3b66938..37a4c5ebb 100644 --- a/api/chalicelib/core/product_analytics/events.py +++ b/api/chalicelib/core/product_analytics/events.py @@ -12,7 +12,7 @@ def get_events(project_id: int, page: schemas.PaginatedSchema): with ClickHouseClient() as ch_client: r = ch_client.format( """SELECT COUNT(1) OVER () AS total, - event_name, display_name, description, + event_name AS name, display_name, description, auto_captured FROM product_analytics.all_events WHERE project_id=%(project_id)s @@ -26,9 +26,9 @@ def get_events(project_id: int, page: schemas.PaginatedSchema): for i, row in enumerate(rows): row["id"] = f"event_{i}" row["icon"] = None - row["type"] = "string" + row["possibleTypes"] = ["String"] row.pop("total") - return {"total": total, "list": rows} + return {"total": total, "list": helper.list_to_camel_case(rows)} def search_events(project_id: int, data: schemas.EventsSearchPayloadSchema): diff --git a/api/chalicelib/core/product_analytics/properties.py b/api/chalicelib/core/product_analytics/properties.py index 7794814be..a62f243f2 100644 --- a/api/chalicelib/core/product_analytics/properties.py +++ b/api/chalicelib/core/product_analytics/properties.py @@ -7,10 +7,12 @@ def get_all_properties(project_id: int, page: schemas.PaginatedSchema): with ClickHouseClient() as ch_client: r = ch_client.format( """SELECT COUNT(1) OVER () AS total, - property_name, - display_name - FROM product_analytics.all_properties + property_name AS name, display_name, + array_agg(DISTINCT event_properties.value_type) AS possible_types + FROM product_analytics.all_properties + LEFT JOIN product_analytics.event_properties USING (project_id, property_name) WHERE all_properties.project_id=%(project_id)s + GROUP BY property_name,display_name ORDER BY display_name LIMIT %(limit)s OFFSET %(offset)s;""", parameters={"project_id": project_id,