Skip to content

Commit 0b5733d

Browse files
authored
Include ProjectMessages in the JSON output headers section #1659 (#1662)
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent 81e05b9 commit 0b5733d

25 files changed

+1369
-1305
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ v34.10.2 (unreleased)
1616
- Add the ability to export filtered QuerySet of a FilterView into the JSON format.
1717
https://github.com/aboutcode-org/scancode.io/pull/1572
1818

19+
- Include ``ProjectMessage`` records in the JSON output ``headers`` section.
20+
https://github.com/aboutcode-org/scancode.io/issues/1659
21+
1922
v34.10.1 (2025-03-26)
2023
---------------------
2124

scanpipe/pipes/output.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,15 @@ def encode(data):
224224
return json.dumps(data, indent=2, cls=DjangoJSONEncoder)
225225

226226
def get_headers(self, project):
227+
from scanpipe.api.serializers import ProjectMessageSerializer
227228
from scanpipe.api.serializers import RunSerializer
228229

229230
runs = project.runs.all()
230231
runs = RunSerializer(runs, many=True, exclude_fields=("url", "project"))
231232

233+
messages = project.projectmessages.all()
234+
messages = ProjectMessageSerializer(messages, many=True)
235+
232236
other_tools = [f"pkg:pypi/scancode-toolkit@{scancode_toolkit_version}"]
233237

234238
headers = {
@@ -242,6 +246,7 @@ def get_headers(self, project):
242246
"settings": project.settings,
243247
"input_sources": project.get_inputs_with_source(),
244248
"runs": runs.data,
249+
"messages": messages.data,
245250
"extra_data": project.extra_data,
246251
}
247252
yield self.encode(headers)

scanpipe/tests/data/asgiref/asgiref-3.3.0_load_inventory_expected.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"execution_time": null
2727
}
2828
],
29+
"messages": [],
2930
"extra_data": {}
3031
}
3132
],

scanpipe/tests/data/asgiref/asgiref-3.3.0_scanpipe_output.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"execution_time": null
4343
}
4444
],
45+
"messages": [],
4546
"extra_data": {}
4647
}
4748
],

0 commit comments

Comments
 (0)