feat(api): changed speed_location response
This commit is contained in:
parent
9411f0f576
commit
89b3d84230
2 changed files with 4 additions and 4 deletions
|
|
@ -1069,7 +1069,7 @@ def get_speed_index_location(project_id, startTimestamp=TimeUTC.now(delta_days=-
|
|||
pg_sub_query.append("pages.speed_index>0")
|
||||
|
||||
with pg_client.PostgresClient() as cur:
|
||||
pg_query = f"""SELECT sessions.user_country, AVG(pages.speed_index) AS avg
|
||||
pg_query = f"""SELECT sessions.user_country, AVG(pages.speed_index) AS value
|
||||
FROM events.pages INNER JOIN public.sessions USING (session_id)
|
||||
WHERE {" AND ".join(pg_sub_query)}
|
||||
GROUP BY sessions.user_country
|
||||
|
|
@ -1087,7 +1087,7 @@ def get_speed_index_location(project_id, startTimestamp=TimeUTC.now(delta_days=-
|
|||
avg = cur.fetchone()["avg"]
|
||||
else:
|
||||
avg = 0
|
||||
return {"avg": avg, "chart": helper.list_to_camel_case(rows)}
|
||||
return {"value": avg, "chart": helper.list_to_camel_case(rows), "unit": schemas.TemplatePredefinedUnits.millisecond}
|
||||
|
||||
|
||||
def get_pages_response_time(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
||||
|
|
|
|||
|
|
@ -1046,7 +1046,7 @@ def get_speed_index_location(project_id, startTimestamp=TimeUTC.now(delta_days=-
|
|||
ch_sub_query += meta_condition
|
||||
|
||||
with ch_client.ClickHouseClient() as ch:
|
||||
ch_query = f"""SELECT pages.user_country, COALESCE(avgOrNull(pages.speed_index),0) AS avg
|
||||
ch_query = f"""SELECT pages.user_country, COALESCE(avgOrNull(pages.speed_index),0) AS value
|
||||
FROM pages {"INNER JOIN sessions_metadata USING(session_id)" if len(meta_condition) > 0 else ""}
|
||||
WHERE {" AND ".join(ch_sub_query)}
|
||||
GROUP BY pages.user_country
|
||||
|
|
@ -1059,7 +1059,7 @@ def get_speed_index_location(project_id, startTimestamp=TimeUTC.now(delta_days=-
|
|||
FROM pages {"INNER JOIN sessions_metadata USING(session_id)" if len(meta_condition) > 0 else ""}
|
||||
WHERE {" AND ".join(ch_sub_query)};"""
|
||||
avg = ch.execute(query=ch_query, params=params)[0]["avg"] if len(rows) > 0 else 0
|
||||
return {"avg": avg, "chart": helper.list_to_camel_case(rows)}
|
||||
return {"value": avg, "chart": helper.list_to_camel_case(rows), "unit": schemas.TemplatePredefinedUnits.millisecond}
|
||||
|
||||
|
||||
def get_pages_response_time(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue