Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Better SQL SELECT instead of a timeout query #4363

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions web/server/codechecker_server/api/report_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,39 +534,31 @@ def get_source_component_file_query(

def get_reports_by_bugpath_filter(session, file_filter_q) -> Set[int]:
"""
This function returns a set of report IDs that are related to any file
This function returns a query for report IDs that are related to any file
described by the query in the second parameter, either because their bug
path goes through these files, or there is any bug note, etc. in these
files.
"""
def first_col_values(query):
"""
This function executes a query and returns the set of first columns'
values.
"""
return set(map(lambda x: x[0], query.all()))

report_ids = set()

q = session.query(Report.id) \
q_report = session.query(Report.id) \
.join(File, File.id == Report.file_id) \
.filter(file_filter_q)

report_ids.update(first_col_values(q))

q = session.query(BugPathEvent.report_id) \
q_bugpathevent = session.query(BugPathEvent.report_id) \
.join(File, File.id == BugPathEvent.file_id) \
.filter(file_filter_q)

report_ids.update(first_col_values(q))
q_bugreportpoint = session.query(BugReportPoint.report_id) \
.join(File, File.id == BugReportPoint.file_id) \
.filter(file_filter_q)

q = session.query(ExtendedReportData.report_id) \
q_extendedreportdata = session.query(ExtendedReportData.report_id) \
.join(File, File.id == ExtendedReportData.file_id) \
.filter(file_filter_q)

report_ids.update(first_col_values(q))

return report_ids
return q_report.union(
q_bugpathevent,
q_extendedreportdata,
q_bugreportpoint)


def get_reports_by_components(session, component_names: List[str]) -> Set[int]:
Expand Down
Loading