@@ -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})
0 commit comments