refactor(chalice): changed product analytics to return full filters with possible types
This commit is contained in:
parent
bb17f672fe
commit
856e716507
3 changed files with 9 additions and 7 deletions
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue