From b9193ccc439fbf0891ecc46723c7586892696232 Mon Sep 17 00:00:00 2001 From: lfjnascimento Date: Tue, 19 Nov 2024 16:13:21 -0300 Subject: [PATCH] feat: make hardwareDetails endpoint use only the tree heads Close #527 --- backend/kernelCI_app/views/hardwareDetailsView.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/kernelCI_app/views/hardwareDetailsView.py b/backend/kernelCI_app/views/hardwareDetailsView.py index d917934b..989a9dc8 100644 --- a/backend/kernelCI_app/views/hardwareDetailsView.py +++ b/backend/kernelCI_app/views/hardwareDetailsView.py @@ -118,6 +118,10 @@ def generate_test_dict(): } +def is_record_in_tree_head(record, tree): + return record["checkout_git_commit_hash"] == tree["headGitCommitHash"] + + # disable django csrf protection https://docs.djangoproject.com/en/5.0/ref/csrf/ # that protection is recommended for ‘unsafe’ methods (POST, PUT, and DELETE) # but we are using POST here just to follow the convention to use the request body @@ -137,7 +141,7 @@ def sanitize_records(self, records, selected_trees): for r in records: current_tree = get_current_selected_tree(r, selected_trees) - if not current_tree: + if not current_tree or not is_record_in_tree_head(r, current_tree): continue build_id = r["build_id"]