From f8177fbbb7b661f80e8ea1168bdb8efe949365a4 Mon Sep 17 00:00:00 2001 From: Zhao Jianing <18910855655@163.com> Date: Wed, 21 Oct 2026 13:14:40 +0800 Subject: [PATCH] fix: bug issue open time card plots the all-issue series The card is titled and weighted as Bug Issue Open Time (community_service_and_support.metrics.bug_issue_open_time), but its chart tabs read metricCommunity.issueOpenTimeAvg/Mid and summaryCommunity.issueOpenTimeAvg/Mid - the open time of ALL issues. The GraphQL layer declares bugIssueOpenTimeAvg { mean, median } and bugIssueOpenTimeMid in both metricCommunity (query.graphql:174-175) and summaryCommunity (:361-364), and a grep shows the bug* fields are consumed nowhere in the app - the card, its avg/median summary reference lines and the downloaded image all render the wrong series. Switch the four keys to bugIssueOpenTime*, and extract the tab map into an exported getChartTabs(t) factory so the key contract is testable (same pattern as the merged #407 processLanguages export). --- .../BugIssueOpenTime.test.tsx | 16 ++++++++++ .../BugIssueOpenTime.tsx | 29 ++++++++++--------- 2 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 apps/web/src/modules/analyze/DataView/CommunityServiceSupport/BugIssueOpenTime.test.tsx diff --git a/apps/web/src/modules/analyze/DataView/CommunityServiceSupport/BugIssueOpenTime.test.tsx b/apps/web/src/modules/analyze/DataView/CommunityServiceSupport/BugIssueOpenTime.test.tsx new file mode 100644 index 0000000000..f5909afb61 --- /dev/null +++ b/apps/web/src/modules/analyze/DataView/CommunityServiceSupport/BugIssueOpenTime.test.tsx @@ -0,0 +1,16 @@ +jest.mock('@modules/analyze/components/CardDropDownMenu', () => ({ + __esModule: true, + default: () => null, +})); + +import { getChartTabs } from './BugIssueOpenTime'; + +describe('getChartTabs', () => { + it('plots the bug-issue open time series, not the all-issue one', () => { + const tabs = getChartTabs((key) => key); + expect(tabs['1'].yKey).toBe('metricCommunity.bugIssueOpenTimeAvg'); + expect(tabs['2'].yKey).toBe('metricCommunity.bugIssueOpenTimeMid'); + expect(tabs['1'].summaryKey).toBe('summaryCommunity.bugIssueOpenTimeAvg'); + expect(tabs['2'].summaryKey).toBe('summaryCommunity.bugIssueOpenTimeMid'); + }); +}); diff --git a/apps/web/src/modules/analyze/DataView/CommunityServiceSupport/BugIssueOpenTime.tsx b/apps/web/src/modules/analyze/DataView/CommunityServiceSupport/BugIssueOpenTime.tsx index 10fdfa7993..6a73b0dfa0 100644 --- a/apps/web/src/modules/analyze/DataView/CommunityServiceSupport/BugIssueOpenTime.tsx +++ b/apps/web/src/modules/analyze/DataView/CommunityServiceSupport/BugIssueOpenTime.tsx @@ -14,6 +14,20 @@ import { DataContainerResult } from '@modules/analyze/type'; import CardDropDownMenu from '@modules/analyze/components/CardDropDownMenu'; import { toTransString } from '@common/utils'; +export const getChartTabs = (t: (key: string) => string) => ({ + '1': { + legendName: t('analyze:average'), + xKey: 'grimoireCreationDate', + yKey: 'metricCommunity.bugIssueOpenTimeAvg', + summaryKey: 'summaryCommunity.bugIssueOpenTimeAvg', + }, + '2': { + legendName: t('analyze:median'), + xKey: 'grimoireCreationDate', + yKey: 'metricCommunity.bugIssueOpenTimeMid', + summaryKey: 'summaryCommunity.bugIssueOpenTimeMid', + }, +}); const BugIssueOpenTime = () => { const { t, i18n } = useTranslation(); @@ -22,20 +36,7 @@ const BugIssueOpenTime = () => { { label: t('analyze:median'), value: '2' }, ]; - const chartTabs = { - '1': { - legendName: t('analyze:average'), - xKey: 'grimoireCreationDate', - yKey: 'metricCommunity.issueOpenTimeAvg', - summaryKey: 'summaryCommunity.issueOpenTimeAvg', - }, - '2': { - legendName: t('analyze:median'), - xKey: 'grimoireCreationDate', - yKey: 'metricCommunity.issueOpenTimeMid', - summaryKey: 'summaryCommunity.issueOpenTimeMid', - }, - }; + const chartTabs = getChartTabs(t); const [tab, setTab] = useState('1'); type TabValue = keyof typeof chartTabs;