feat(api): changed slowest_domains response
This commit is contained in:
parent
23a98d83d7
commit
fa7a57eb3f
2 changed files with 4 additions and 4 deletions
|
|
@ -1721,7 +1721,7 @@ def get_slowest_domains(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
|||
with pg_client.PostgresClient() as cur:
|
||||
pg_query = f"""SELECT
|
||||
resources.url_host AS domain,
|
||||
AVG(resources.duration) AS avg
|
||||
AVG(resources.duration) AS value
|
||||
FROM events.resources INNER JOIN sessions USING (session_id)
|
||||
WHERE {" AND ".join(pg_sub_query)}
|
||||
GROUP BY resources.url_host
|
||||
|
|
@ -1740,7 +1740,7 @@ def get_slowest_domains(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
|||
avg = cur.fetchone()["avg"]
|
||||
else:
|
||||
avg = 0
|
||||
return {"avg": avg, "partition": rows}
|
||||
return {"value": avg, "chart": rows, "unit": schemas.TemplatePredefinedUnits.millisecond}
|
||||
|
||||
|
||||
def get_errors_per_domains(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
||||
|
|
|
|||
|
|
@ -1661,7 +1661,7 @@ def get_slowest_domains(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
|||
|
||||
with ch_client.ClickHouseClient() as ch:
|
||||
ch_query = f"""SELECT resources.url_host AS domain,
|
||||
COALESCE(avgOrNull(resources.duration),0) AS avg
|
||||
COALESCE(avgOrNull(resources.duration),0) AS value
|
||||
FROM resources {"INNER JOIN sessions_metadata USING(session_id)" if len(meta_condition) > 0 else ""}
|
||||
WHERE {" AND ".join(ch_sub_query)}
|
||||
GROUP BY resources.url_host
|
||||
|
|
@ -1675,7 +1675,7 @@ def get_slowest_domains(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
|||
FROM resources {"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, "partition": rows}
|
||||
return {"value": avg, "chart": rows, "unit": schemas.TemplatePredefinedUnits.millisecond}
|
||||
|
||||
|
||||
def get_errors_per_domains(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue