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

View File

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

View File

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

View File

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

View File

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

View File

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