Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: show tag in history chart x axis #903

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backend/kernelCI_app/typeModels/treeCommits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)


Expand All @@ -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
Expand Down
44 changes: 25 additions & 19 deletions backend/kernelCI_app/views/treeCommitsHistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down Expand Up @@ -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"
]
Expand Down Expand Up @@ -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
Expand All @@ -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 (
Expand All @@ -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,
Expand Down Expand Up @@ -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"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -120,6 +141,7 @@ const CommitNavigationGraph = ({
type TCommitValue = {
commitHash: string;
commitName?: string;
commitTags?: string[];
earliestStartTime?: string;
};

Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -186,6 +210,7 @@ const CommitNavigationGraph = ({
},
},
];

return (
<QuerySwitcher
status={status}
Expand Down Expand Up @@ -225,9 +250,8 @@ const CommitNavigationGraph = ({

isCurrentCommit =
treeId === commitData[parsedPossibleIndex].commitHash;
displayText = commitData[
parsedPossibleIndex
]?.commitHash.slice(0, graphDisplaySize);

displayText = getChartXLabel(commitData[parsedPossibleIndex]);
}

return (
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/Tooltip/CommitTagTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import CopyButton from '@/components/Button/CopyButton';

import { Tooltip, TooltipTrigger, TooltipContent } from './Tooltip';

interface gitValues {
export interface gitValues {
commitTags?: string[];
commitHash?: string;
commitName?: string;
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/types/tree/TreeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export type TTestByCommitHashResponse = {
export type PaginatedCommitHistoryByTree = {
git_commit_hash: string;
git_commit_name?: string;
git_commit_tags?: string[];
earliest_start_time: string;
builds: {
valid: number;
Expand Down