Skip to content

Commit

Permalink
fix: speedup flag filtering in GraphQL API (#223)
Browse files Browse the repository at this point in the history
Speed up filtering by flags in GraphQL endpoints by rewriting the search function to be able to compute faster on average.
Change it to exit each of the nested for loops quicker by not going through the entire iterator.
  • Loading branch information
JerrySentry authored Nov 2, 2023
1 parent 6462963 commit 7c1a3d4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions services/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,17 @@ def sessions_with_specific_flags(


def files_in_sessions(commit_report: Report, session_ids: List[int]) -> List[str]:
return [
file.name
for file in commit_report
if any(
[
any([session.id in session_ids for session in line.sessions])
for line in file
if line
]
)
]
files, session_ids = [], set(session_ids)
for file in commit_report:
found = False
for line in file:
if line:
for session in line.sessions:
if session.id in session_ids:
found = True
break
if found:
break
if found:
files.append(file.name)
return files

0 comments on commit 7c1a3d4

Please sign in to comment.