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 = """
|
||||
SELECT COUNT(*) FROM (
|
||||
SELECT DISTINCT ON (uts.session_id) uts.test_id
|
||||
FROM ut_tests_signals uts
|
||||
WHERE uts.duration IS NULL AND uts.task_id IS NULL
|
||||
ORDER BY uts.session_id, uts.timestamp DESC
|
||||
) AS latest_signals
|
||||
WHERE latest_signals.test_id = ut.test_id
|
||||
WITH RankedSessions AS (
|
||||
SELECT *,
|
||||
ROW_NUMBER() OVER (PARTITION BY session_id ORDER BY timestamp DESC) as rn
|
||||
FROM ut_tests_signals
|
||||
WHERE test_id = %(test_id)s AND task_id IS NULL
|
||||
)
|
||||
SELECT COUNT(DISTINCT session_id) AS live_count
|
||||
FROM RankedSessions
|
||||
WHERE rn = 1 AND status = 'begin'
|
||||
"""
|
||||
|
||||
select_columns = [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue