fix(api): tests live count
This commit is contained in:
parent
3d10d0836f
commit
606373a448
1 changed files with 9 additions and 7 deletions
|
|
@ -117,13 +117,15 @@ def get_ut_test(project_id: int, test_id: int):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
live_count_sql = """
|
live_count_sql = """
|
||||||
SELECT COUNT(*) FROM (
|
WITH RankedSessions AS (
|
||||||
SELECT DISTINCT ON (uts.session_id) uts.test_id
|
SELECT *,
|
||||||
FROM ut_tests_signals uts
|
ROW_NUMBER() OVER (PARTITION BY session_id ORDER BY timestamp DESC) as rn
|
||||||
WHERE uts.duration IS NULL AND uts.task_id IS NULL
|
FROM ut_tests_signals
|
||||||
ORDER BY uts.session_id, uts.timestamp DESC
|
WHERE test_id = %(test_id)s AND task_id IS NULL
|
||||||
) AS latest_signals
|
)
|
||||||
WHERE latest_signals.test_id = ut.test_id
|
SELECT COUNT(DISTINCT session_id) AS live_count
|
||||||
|
FROM RankedSessions
|
||||||
|
WHERE rn = 1 AND status = 'begin'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
select_columns = [
|
select_columns = [
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue