Skip to content

Commit

Permalink
feat: add types to issue filters
Browse files Browse the repository at this point in the history
- use tuple (issue_id, issue_version) shape to pass issue filters
- create function to format issue name with version

Part of #739
  • Loading branch information
Francisco2002 committed Jan 31, 2025
1 parent 2d1f227 commit e7cf6c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/kernelCI_app/typeModels/commonDetails.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import defaultdict
from datetime import datetime
from typing import Dict, List, Optional, Set, Union
from typing import Dict, List, Optional, Set, Union, Tuple

from kernelCI_app.typeModels.issues import Issue
from pydantic import BaseModel
Expand Down Expand Up @@ -98,7 +98,7 @@ class GlobalFilters(BaseModel):


class LocalFilters(BaseModel):
issues: List[str]
issues: List[Tuple[str, Optional[int]]]


class DetailsFilters(BaseModel):
Expand Down
4 changes: 3 additions & 1 deletion dashboard/src/types/commonDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export type GlobalFilters = {
compilers: string[];
};

export type IssueFilterItem = [string, string?];

export type LocalFilters = {
issues: string[];
issues: IssueFilterItem[];
};

export type DetailsFilters = {
Expand Down
12 changes: 12 additions & 0 deletions dashboard/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
BuildsTableBuild,
BuildStatus,
StatusCount,
TIssue,
} from '@/types/general';
import { sanitizeTableValue } from '@/components/Table/tableUtils';
import type { ISummaryItem } from '@/components/Tabs/Summary';
Expand Down Expand Up @@ -206,3 +207,14 @@ export const isEmptyObject = (obj: Record<string, unknown>): boolean => {
}
return true;
};

type TIssueFilter = Pick<TIssue, 'id' | 'version'>;

export const getIssueFilterLabel = (issueFilter: TIssueFilter): string => {
const issueId = issueFilter.id;
const issueVersion = issueFilter.version;

if (!issueVersion) return issueId;

return `${issueId} v.${issueVersion}`;
};

0 comments on commit e7cf6c7

Please sign in to comment.