From f993c81093df21b3f7a6a62cfdaba7d49546e542 Mon Sep 17 00:00:00 2001 From: francisco Date: Mon, 10 Feb 2025 13:36:48 -0300 Subject: [PATCH 1/2] feat(api): add commit tags in commit history - add commit tags in tree commit history endpoint - add commit tags in tree commit history validation Part of #894 --- .../kernelCI_app/typeModels/treeCommits.py | 4 +- .../kernelCI_app/views/treeCommitsHistory.py | 44 +++++++++++-------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/backend/kernelCI_app/typeModels/treeCommits.py b/backend/kernelCI_app/typeModels/treeCommits.py index 29fcab542..9b2a04297 100644 --- a/backend/kernelCI_app/typeModels/treeCommits.py +++ b/backend/kernelCI_app/typeModels/treeCommits.py @@ -6,7 +6,8 @@ from kernelCI_app.typeModels.treeListing import TestStatusCount from kernelCI_app.typeModels.databases import ( Checkout__GitCommitHash, - Checkout__GitCommitName + Checkout__GitCommitName, + Checkout__GitCommitTags ) @@ -22,6 +23,7 @@ class TreeCommitsQueryParameters(BaseModel): class TreeCommitsData(BaseModel): git_commit_hash: Checkout__GitCommitHash git_commit_name: Checkout__GitCommitName + git_commit_tags: Checkout__GitCommitTags earliest_start_time: datetime builds: BuildStatusCount boots: TestStatusCount diff --git a/backend/kernelCI_app/views/treeCommitsHistory.py b/backend/kernelCI_app/views/treeCommitsHistory.py index 6c561974e..2556a74d7 100644 --- a/backend/kernelCI_app/views/treeCommitsHistory.py +++ b/backend/kernelCI_app/views/treeCommitsHistory.py @@ -62,24 +62,25 @@ def sanitize_rows(self, rows: Dict) -> List: { "git_commit_hash": row[0], "git_commit_name": row[1], - "earliest_start_time": row[2], - "build_duration": row[3], - "architecture": row[4], - "compiler": row[5], - "config_name": row[6], - "build_valid": row[7], - "test_path": row[8], - "test_status": row[9], - "test_duration": row[10], - "hardware_compatibles": row[11], - "test_environment_misc": row[12], - "build_id": row[13], - "build_misc": row[14], - "test_id": row[15], - "incidents_id": row[16], - "incidents_test_id": row[17], - "issue_id": row[18], - "issue_version": row[19], + "git_commit_tags": row[2], + "earliest_start_time": row[3], + "build_duration": row[4], + "architecture": row[5], + "compiler": row[6], + "config_name": row[7], + "build_valid": row[8], + "test_path": row[9], + "test_status": row[10], + "test_duration": row[11], + "hardware_compatibles": row[12], + "test_environment_misc": row[13], + "build_id": row[14], + "build_misc": row[15], + "test_id": row[16], + "incidents_id": row[17], + "incidents_test_id": row[18], + "issue_id": row[19], + "issue_version": row[20], } for row in rows ] @@ -341,6 +342,7 @@ def _process_rows(self, rows: Dict) -> None: if commit_hash not in self.commit_hashes: self.commit_hashes[commit_hash] = self._create_commit_entry() self.commit_hashes[commit_hash]["commit_name"] = row["git_commit_name"] + self.commit_hashes[commit_hash]["commit_tags"] = row["git_commit_tags"] self.commit_hashes[commit_hash]["earliest_start_time"] = row[ "earliest_start_time" ] @@ -406,11 +408,12 @@ def get(self, request, commit_hash: Optional[str]) -> Response: query = f""" WITH earliest_commits AS ( SELECT - id, + id, git_commit_hash, git_commit_name, git_repository_branch, git_repository_url, + git_commit_tags, origin, start_time, time_order @@ -421,6 +424,7 @@ def get(self, request, commit_hash: Optional[str]) -> Response: git_commit_name, git_repository_branch, git_repository_url, + git_commit_tags, origin, start_time, ROW_NUMBER() OVER ( @@ -445,6 +449,7 @@ def get(self, request, commit_hash: Optional[str]) -> Response: SELECT c.git_commit_hash, c.git_commit_name, + c.git_commit_tags, c.start_time, b.duration, b.architecture, @@ -500,6 +505,7 @@ def get(self, request, commit_hash: Optional[str]) -> Response: { "git_commit_hash": key, "git_commit_name": value["commit_name"], + "git_commit_tags": value["commit_tags"], "earliest_start_time": value["earliest_start_time"], "builds": { "valid": value["builds_count"]["true"], From 7251fbc54d9b7a21d337f1e71ebd3719240500ca Mon Sep 17 00:00:00 2001 From: francisco Date: Mon, 10 Feb 2025 15:01:30 -0300 Subject: [PATCH 2/2] feat(dashboard): add commit tag on x axis Close #894 --- .../CommitNavigationGraph.tsx | 30 +++++++++++++++++-- .../components/Tooltip/CommitTagTooltip.tsx | 2 +- dashboard/src/types/tree/TreeDetails.tsx | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/dashboard/src/components/CommitNavigationGraph/CommitNavigationGraph.tsx b/dashboard/src/components/CommitNavigationGraph/CommitNavigationGraph.tsx index 980f89e5a..090c61099 100644 --- a/dashboard/src/components/CommitNavigationGraph/CommitNavigationGraph.tsx +++ b/dashboard/src/components/CommitNavigationGraph/CommitNavigationGraph.tsx @@ -17,8 +17,29 @@ import type { TFilter } from '@/types/general'; import { MemoizedSectionError } from '@/components/DetailsPages/SectionError'; +import type { gitValues } from '@/components/Tooltip/CommitTagTooltip'; + const graphDisplaySize = 8; +export const getChartXLabel = ({ + commitTags, + commitHash, + commitName, +}: gitValues): string => { + let content = commitHash ?? commitName ?? ''; + if (commitTags && commitTags.length > 0) { + content = commitTags[0]; + + if (content.length > graphDisplaySize) { + content = `...${content.slice(-graphDisplaySize)}`; + } + } else { + content = `${content.slice(0, graphDisplaySize)}`; + } + + return content; +}; + interface ICommitNavigationGraph { origin: string; currentPageTab: string; @@ -120,6 +141,7 @@ const CommitNavigationGraph = ({ type TCommitValue = { commitHash: string; commitName?: string; + commitTags?: string[]; earliestStartTime?: string; }; @@ -157,8 +179,10 @@ const CommitNavigationGraph = ({ commitData.unshift({ commitHash: item.git_commit_hash, commitName: item.git_commit_name, + commitTags: item.git_commit_tags, earliestStartTime: item.earliest_start_time, }); + xAxisIndexes.push(index); }); @@ -186,6 +210,7 @@ const CommitNavigationGraph = ({ }, }, ]; + return (