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 searching result on latest version dependency analysis #64

Merged
merged 1 commit into from
Aug 6, 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
15 changes: 9 additions & 6 deletions isabl_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
Returns:
list: of tuples (result_value, analysis primary key).
"""
results = []
targets = {i.pk for i in targets or []}
references = {i.pk for i in references or []}
analyses = {i.pk for i in analyses or []}
Expand All @@ -85,6 +84,7 @@
experiment_results.append(i)

# Filter candidates by same targets/references/analyses
candidates = []
for i in experiment_results:
if targets and {j.pk for j in i.targets}.difference(
targets
Expand All @@ -101,6 +101,14 @@
): # pragma: no cover
continue

candidates.append(i)

# Return latest if more than 1 result and version is `latest`.
if len(candidates) > 1 and application_version == "latest":
candidates = sorted(candidates, key=lambda x: x.pk, reverse=True)[:1]

Check warning on line 108 in isabl_cli/utils.py

View check run for this annotation

Codecov / codecov/patch

isabl_cli/utils.py#L108

Added line #L108 was not covered by tests

results = []
for i in candidates:
results_dict = i if result_key == "storage_url" else i.results
result = results_dict.get(result_key)
results.append((result, i.pk))
Expand All @@ -115,11 +123,6 @@
f"Expected status '{status}' for result '{result_key}' did not match: "
f"{i.pk}({i.application.name} {i.application.version}) is {i.status}"
)

# Return latest if more than 1 result and version is `latest`.
if len(results) > 2 and application_version == "latest":
results = sorted(results, key=lambda x: x[1], reverse=True)[:1]

return results


Expand Down
Loading