refactor: 修改查询方法

This commit is contained in:
CaptainB 2022-01-20 12:48:19 +08:00 committed by song-tianyang
parent c4ed4d768a
commit b473863ee1
6 changed files with 106 additions and 50 deletions

View File

@ -495,12 +495,19 @@
OR
version_id = (SELECT project_version.id
FROM api_definition tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = api_definition.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(tmp.update_time) DESC
JOIN project_version
ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
FROM api_definition tmp2
JOIN project_version
ON tmp2.project_id =
project_version.project_id AND
version_id =
project_version.id AND
latest = TRUE
WHERE tmp.ref_id = tmp2.ref_id)
WHERE tmp.ref_id = api_definition.ref_id
ORDER BY tmp.update_time DESC
LIMIT 1)
)
</if>
@ -758,14 +765,21 @@
LIMIT 1)
OR
version_id = (SELECT project_version.id
FROM api_definition tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = api_definition.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(tmp.update_time) DESC
LIMIT 1)
FROM api_definition tmp
JOIN project_version
ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
FROM api_definition tmp2
JOIN project_version
ON tmp2.project_id =
project_version.project_id AND
version_id =
project_version.id AND
latest = TRUE
WHERE tmp.ref_id = tmp2.ref_id)
WHERE tmp.ref_id = api_definition.ref_id
ORDER BY tmp.update_time DESC
LIMIT 1)
)
</if>
</where>

View File

@ -335,12 +335,19 @@
OR
version_id = (SELECT project_version.id
FROM api_scenario tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = api_scenario.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(tmp.update_time) DESC
JOIN project_version
ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
FROM api_scenario tmp2
JOIN project_version
ON tmp2.project_id =
project_version.project_id AND
version_id =
project_version.id AND
latest = TRUE
WHERE tmp.ref_id = tmp2.ref_id)
WHERE tmp.ref_id = api_scenario.ref_id
ORDER BY tmp.update_time DESC
LIMIT 1)
)
</if>

View File

@ -183,12 +183,19 @@
OR
version_id = (SELECT project_version.id
FROM load_test tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = load_test.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(tmp.update_time) DESC
JOIN project_version
ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
FROM load_test tmp2
JOIN project_version
ON tmp2.project_id =
project_version.project_id AND
version_id =
project_version.id AND
latest = TRUE
WHERE tmp.ref_id = tmp2.ref_id)
WHERE tmp.ref_id = load_test.ref_id
ORDER BY tmp.update_time DESC
LIMIT 1)
)
</if>

View File

@ -144,12 +144,19 @@
OR
version_id = (SELECT project_version.id
FROM test_case tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = test_case.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(tmp.update_time) DESC
JOIN project_version
ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
FROM test_case tmp2
JOIN project_version
ON tmp2.project_id =
project_version.project_id AND
version_id =
project_version.id AND
latest = TRUE
WHERE tmp.ref_id = tmp2.ref_id)
WHERE tmp.ref_id = test_case.ref_id
ORDER BY tmp.update_time DESC
LIMIT 1)
)
</if>
@ -637,12 +644,19 @@
OR
version_id = (SELECT project_version.id
FROM test_case tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = test_case.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(tmp.update_time) DESC
JOIN project_version
ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
FROM test_case tmp2
JOIN project_version
ON tmp2.project_id =
project_version.project_id AND
version_id =
project_version.id AND
latest = TRUE
WHERE tmp.ref_id = tmp2.ref_id)
WHERE tmp.ref_id = test_case.ref_id
ORDER BY tmp.update_time DESC
LIMIT 1)
)
</if>

View File

@ -188,12 +188,19 @@
OR
version_id = (SELECT project_version.id
FROM test_case tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = test_case.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(tmp.update_time) DESC
JOIN project_version
ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
FROM test_case tmp2
JOIN project_version
ON tmp2.project_id =
project_version.project_id AND
version_id =
project_version.id AND
latest = TRUE
WHERE tmp.ref_id = tmp2.ref_id)
WHERE tmp.ref_id = test_case.ref_id
ORDER BY tmp.update_time DESC
LIMIT 1)
)
</if>

View File

@ -184,12 +184,19 @@
OR
version_id = (SELECT project_version.id
FROM test_case tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = test_case.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(tmp.update_time) DESC
JOIN project_version
ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
FROM test_case tmp2
JOIN project_version
ON tmp2.project_id =
project_version.project_id AND
version_id =
project_version.id AND
latest = TRUE
WHERE tmp.ref_id = tmp2.ref_id)
WHERE tmp.ref_id = test_case.ref_id
ORDER BY tmp.update_time DESC
LIMIT 1)
)
</if>