Skip to content

Commit 5ea5edf

Browse files
authored
[FIX] Split regression_testid_passed query to optimize (#834)
* Split query for get_info_for_pr_comment Signed-off-by: Tarun Arora <tarun.arora.030402@gmail.com> * Fix pycodestyle issues Signed-off-by: Tarun Arora <tarun.arora.030402@gmail.com> --------- Signed-off-by: Tarun Arora <tarun.arora.030402@gmail.com>
1 parent c69a109 commit 5ea5edf

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

mod_ci/controllers.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,15 @@ def set_avg_time(platform, process_type: str, time_taken: int) -> None:
15481548

15491549
def get_info_for_pr_comment(test_id: int) -> PrCommentInfo:
15501550
"""Return info about the given test id for use in a PR comment."""
1551+
regression_testid_passed = g.db.query(TestResult.regression_test_id).outerjoin(
1552+
TestResultFile, TestResult.test_id == TestResultFile.test_id).filter(
1553+
TestResult.test_id == test_id,
1554+
TestResult.expected_rc == TestResult.exit_code,
1555+
and_(
1556+
RegressionTestOutput.regression_id == TestResult.regression_test_id,
1557+
RegressionTestOutput.ignore.is_(True)
1558+
)).distinct().subquery()
1559+
15511560
regression_testid_passed = g.db.query(TestResult.regression_test_id).outerjoin(
15521561
TestResultFile, TestResult.test_id == TestResultFile.test_id).filter(
15531562
TestResult.test_id == test_id,
@@ -1560,11 +1569,9 @@ def get_info_for_pr_comment(test_id: int) -> PrCommentInfo:
15601569
and_(
15611570
RegressionTestOutputFiles.regression_test_output_id == TestResultFile.regression_test_output_id,
15621571
TestResultFile.got == RegressionTestOutputFiles.file_hashes
1563-
))),
1564-
and_(
1565-
RegressionTestOutput.regression_id == TestResult.regression_test_id,
1566-
RegressionTestOutput.ignore.is_(True),
1567-
))).distinct().subquery()
1572+
)))
1573+
)).distinct().union(g.db.query(regression_testid_passed.c.regression_test_id))
1574+
15681575
passed = g.db.query(label('category_id', Category.id), label(
15691576
'success', count(regressionTestLinkTable.c.regression_id))).filter(
15701577
regressionTestLinkTable.c.regression_id.in_(regression_testid_passed),

0 commit comments

Comments
 (0)