Skip to content

Commit aa1658a

Browse files
committed
Fixes #1307
1 parent af0c825 commit aa1658a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

sonar/projects.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,10 @@ def last_task(self) -> Optional[tasks.Task]:
556556
"""Returns the last analysis background task of a problem, or none if not found"""
557557
return tasks.search_last(component_key=self.key, endpoint=self.endpoint, type="REPORT")
558558

559+
def task_history(self) -> Optional[tasks.Task]:
560+
"""Returns the last analysis background task of a problem, or none if not found"""
561+
return tasks.search_all(component_key=self.key, endpoint=self.endpoint, type="REPORT")
562+
559563
def scanner(self) -> str:
560564
"""Returns the project type (MAVEN, GRADLE, DOTNET, OTHER, UNKNOWN)"""
561565
last_task = self.last_task()
@@ -965,6 +969,14 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
965969
loc_distrib = {m.split("=")[0]: int(m.split("=")[1]) for m in lang_distrib.split(";")}
966970
loc_distrib["total"] = self.loc()
967971
json_data["ncloc"] = loc_distrib
972+
last_task = self.last_task()
973+
json_data["backgroundTasks"] = {}
974+
if last_task:
975+
json_data["backgroundTasks"] = {
976+
"lastTaskScannerContext": last_task.scanner_context(),
977+
"lastTaskWarnings": last_task.warnings(),
978+
"taskHistory": [t._json for t in self.task_history()],
979+
}
968980

969981
settings_dict = settings.get_bulk(endpoint=self.endpoint, component=self, settings_list=settings_list, include_not_set=False)
970982
# json_data.update({s.to_json() for s in settings_dict.values() if include_inherited or not s.inherited})

sonar/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,9 @@ def search_last(endpoint: pf.Platform, component_key: str, **params) -> Optional
549549
return bg_tasks[0]
550550

551551

552-
def search_all(endpoint: pf.Platform, component_key: str) -> list[Task]:
552+
def search_all(endpoint: pf.Platform, component_key: str, **params) -> list[Task]:
553553
"""Search all background tasks of a given component"""
554-
return search(endpoint=endpoint, component_key=component_key)
554+
return search(endpoint=endpoint, component_key=component_key, **params)
555555

556556

557557
def _get_suspicious_exclusions(patterns: str) -> list[str]:

0 commit comments

Comments
 (0)