From 2cbae3c490c1705c0d3a57dc33d5913bd341809e Mon Sep 17 00:00:00 2001 From: Efren Lim Date: Tue, 11 Mar 2025 09:31:51 +0800 Subject: [PATCH 1/5] moved granularity to common types folder Signed-off-by: Efren Lim --- .../contributors/config/granularity-tabs.ts | 10 ++-- .../components/shared/types/granularity.ts | 55 ++++++++----------- .../uikit/chart/helpers/formatters.ts | 23 +++++--- .../types/contributors/responses.types.ts | 0 frontend/types/shared/granularity.ts | 8 +++ 5 files changed, 51 insertions(+), 45 deletions(-) create mode 100644 frontend/types/contributors/responses.types.ts create mode 100644 frontend/types/shared/granularity.ts diff --git a/frontend/app/components/modules/project/components/contributors/config/granularity-tabs.ts b/frontend/app/components/modules/project/components/contributors/config/granularity-tabs.ts index f310fbf5f..fc928ba70 100644 --- a/frontend/app/components/modules/project/components/contributors/config/granularity-tabs.ts +++ b/frontend/app/components/modules/project/components/contributors/config/granularity-tabs.ts @@ -1,11 +1,11 @@ import type { GranularityTabs } from '../types/contributors.types'; import { dateOptKeys } from '~/components/modules/project/config/date-options'; -import { Granularity } from '~/components/shared/types/granularity'; +import { Granularity } from '~~/types/shared/granularity'; export const granularityTabs: GranularityTabs[] = [ { label: 'Weekly', - value: Granularity.Weekly, + value: Granularity.WEEKLY, format: 'MMM d', showForKeys: [ dateOptKeys.past90days, @@ -17,7 +17,7 @@ export const granularityTabs: GranularityTabs[] = [ }, { label: 'Monthly', - value: Granularity.Monthly, + value: Granularity.MONTHLY, format: 'MMM, yyyy', showForKeys: [ dateOptKeys.past90days, @@ -32,7 +32,7 @@ export const granularityTabs: GranularityTabs[] = [ }, { label: 'Quarterly', - value: Granularity.Quarterly, + value: Granularity.QUARTERLY, format: 'MMM d', showForKeys: [ dateOptKeys.past180days, @@ -45,7 +45,7 @@ export const granularityTabs: GranularityTabs[] = [ }, { label: 'Yearly', - value: Granularity.Yearly, + value: Granularity.YEARLY, format: 'yyyy', showForKeys: [ dateOptKeys.previous5Year, diff --git a/frontend/app/components/shared/types/granularity.ts b/frontend/app/components/shared/types/granularity.ts index f847cdb23..b3c394780 100644 --- a/frontend/app/components/shared/types/granularity.ts +++ b/frontend/app/components/shared/types/granularity.ts @@ -1,41 +1,34 @@ import { dateOptKeys } from '~/components/modules/project/config/date-options'; - -export enum Granularity { - Daily = 'daily', - Weekly = 'weekly', - Monthly = 'monthly', - Quarterly = 'quarterly', - Yearly = 'yearly' -} +import { Granularity } from '~~/types/shared/granularity'; export const formatByGranularity = { - [Granularity.Daily]: 'MMM d', - [Granularity.Weekly]: 'MMM d', - [Granularity.Monthly]: 'MMM, yyyy', - [Granularity.Quarterly]: 'MMM d', - [Granularity.Yearly]: 'yyyy' + [Granularity.DAILY]: 'MMM d', + [Granularity.WEEKLY]: 'MMM d', + [Granularity.MONTHLY]: 'MMM, yyyy', + [Granularity.QUARTERLY]: 'MMM d', + [Granularity.YEARLY]: 'yyyy' }; export const lineGranularities = { - [dateOptKeys.past90days]: Granularity.Daily, - [dateOptKeys.past180days]: Granularity.Weekly, - [dateOptKeys.past365days]: Granularity.Weekly, - [dateOptKeys.previousQuarter]: Granularity.Daily, - [dateOptKeys.previousYear]: Granularity.Weekly, - [dateOptKeys.previous5Year]: Granularity.Monthly, - [dateOptKeys.previous10Year]: Granularity.Yearly, - [dateOptKeys.alltime]: Granularity.Yearly, - [dateOptKeys.custom]: Granularity.Yearly // TODO: this should be handled differently + [dateOptKeys.past90days]: Granularity.DAILY, + [dateOptKeys.past180days]: Granularity.WEEKLY, + [dateOptKeys.past365days]: Granularity.WEEKLY, + [dateOptKeys.previousQuarter]: Granularity.DAILY, + [dateOptKeys.previousYear]: Granularity.WEEKLY, + [dateOptKeys.previous5Year]: Granularity.MONTHLY, + [dateOptKeys.previous10Year]: Granularity.YEARLY, + [dateOptKeys.alltime]: Granularity.YEARLY, + [dateOptKeys.custom]: Granularity.YEARLY // TODO: this should be handled differently }; export const barGranularities = { - [dateOptKeys.past90days]: Granularity.Weekly, - [dateOptKeys.past180days]: Granularity.Weekly, - [dateOptKeys.past365days]: Granularity.Weekly, - [dateOptKeys.previousQuarter]: Granularity.Weekly, - [dateOptKeys.previousYear]: Granularity.Weekly, - [dateOptKeys.previous5Year]: Granularity.Monthly, - [dateOptKeys.previous10Year]: Granularity.Yearly, - [dateOptKeys.alltime]: Granularity.Yearly, - [dateOptKeys.custom]: Granularity.Yearly // TODO: this should be handled differently + [dateOptKeys.past90days]: Granularity.WEEKLY, + [dateOptKeys.past180days]: Granularity.WEEKLY, + [dateOptKeys.past365days]: Granularity.WEEKLY, + [dateOptKeys.previousQuarter]: Granularity.DAILY, + [dateOptKeys.previousYear]: Granularity.WEEKLY, + [dateOptKeys.previous5Year]: Granularity.MONTHLY, + [dateOptKeys.previous10Year]: Granularity.YEARLY, + [dateOptKeys.alltime]: Granularity.YEARLY, + [dateOptKeys.custom]: Granularity.YEARLY // TODO: this should be handled differently }; diff --git a/frontend/app/components/uikit/chart/helpers/formatters.ts b/frontend/app/components/uikit/chart/helpers/formatters.ts index 6a876c633..9de48ab99 100644 --- a/frontend/app/components/uikit/chart/helpers/formatters.ts +++ b/frontend/app/components/uikit/chart/helpers/formatters.ts @@ -8,7 +8,7 @@ import type { SingleTooltipFormatterParams } from '../types/EChartTypes'; import type { ChartData } from '../types/ChartTypes'; -import { Granularity } from '~/components/shared/types/granularity'; +import { Granularity } from '~~/types/shared/granularity'; import { formatNumber } from '~/components/shared/utils/formatter'; declare type LabelFormatterParams = { @@ -34,7 +34,8 @@ const formatIsoDate = (value: string, format: string) => { return dt.toFormat(luxonFormat); }; -export const axisLabelFormatter = (format: string) => (value: string) => formatDate(value, format); +export const axisLabelFormatter = (format: string) => (value: string) => + formatDate(value, format); export const tooltipLabelFormatter = (params: LabelFormatterParams) => { if (params.axisDimension === 'x') { @@ -59,7 +60,8 @@ const tooltipSingleValue = (params: SingleTooltipFormatterParams) => ` export const tooltipFormatter = ( paramsRaw: TopLevelFormatterParams // Tooltip hover box ): string | HTMLElement | HTMLElement[] => { - const params: MultipleTooltipFormatterParams = paramsRaw as MultipleTooltipFormatterParams; + const params: MultipleTooltipFormatterParams = + paramsRaw as MultipleTooltipFormatterParams; return `${formatDate(params[0]?.name || '', '{MMM} {yyyy}')}
${params .map(tooltipSingleValue) .join('')}`; @@ -71,25 +73,28 @@ const formatDateRange = ( granularity: string ) => { switch (granularity) { - case Granularity.Weekly: - case Granularity.Quarterly: + case Granularity.WEEKLY: + case Granularity.QUARTERLY: return `${formatDate(startDateMillis, 'MMM d')} - ${formatIsoDate( endDateIso, 'MMM d' )}`; - case Granularity.Monthly: + case Granularity.MONTHLY: return `${formatDate(startDateMillis, 'MMM yyyy')}`; - case Granularity.Yearly: + case Granularity.YEARLY: return `${formatDate(startDateMillis, 'yyyy')}`; default: return `${formatDate(startDateMillis, 'MMM d, yyyy')}`; } }; -export const tooltipFormatterWithData = (data: ChartData[], granularity: string) => ( +export const tooltipFormatterWithData = + (data: ChartData[], granularity: string) => + ( paramsRaw: TopLevelFormatterParams // Tooltip hover box ): string | HTMLElement | HTMLElement[] => { - const params: MultipleTooltipFormatterParams = paramsRaw as MultipleTooltipFormatterParams; + const params: MultipleTooltipFormatterParams = + paramsRaw as MultipleTooltipFormatterParams; const index = params[0]?.dataIndex || 0; const dateStr = formatDateRange( diff --git a/frontend/types/contributors/responses.types.ts b/frontend/types/contributors/responses.types.ts new file mode 100644 index 000000000..e69de29bb diff --git a/frontend/types/shared/granularity.ts b/frontend/types/shared/granularity.ts new file mode 100644 index 000000000..a840e9e33 --- /dev/null +++ b/frontend/types/shared/granularity.ts @@ -0,0 +1,8 @@ +export enum Granularity { + HOURLY = 'hourly', + DAILY = 'daily', + WEEKLY = 'weekly', + MONTHLY = 'monthly', + QUARTERLY = 'quarterly', + YEARLY = 'yearly' +} From ddcac04cbd5f3ea9bf1604bd0f8adf0ea9289f05 Mon Sep 17 00:00:00 2001 From: Efren Lim Date: Tue, 11 Mar 2025 09:37:27 +0800 Subject: [PATCH 2/5] moved summary types to common Signed-off-by: Efren Lim --- .../contributors/active-contributors.vue | 29 ++------- .../contributors/active-organizations.vue | 29 ++------- .../contributors/types/contributors.types.ts | 2 +- .../components/development/active-days.vue | 35 +++-------- .../development/average-time-to-merge.vue | 25 ++------ .../development/code-review-engagement.vue | 36 +++-------- .../contributions-outside-work-hours.vue | 49 ++++----------- .../fragments/pull-request-legend-item.vue | 17 ++---- .../development/merge-lead-time.vue | 58 ++++-------------- .../components/development/pull-requests.vue | 59 ++++--------------- .../development/types/active-days.types.ts | 2 +- .../types/average-time-merge.types.ts | 2 +- .../types/code-review-engagement.types.ts | 2 +- .../types/contribution-outside-hours.types.ts | 2 +- .../types/issues-resolution.types.ts | 2 +- .../types/merge-lead-time.types.ts | 2 +- .../development/types/pull-requests.types.ts | 2 +- .../types/wait-time-1st-review.types.ts | 2 +- .../development/wait-time-first-review.vue | 25 ++------ .../project/components/popularity/forks.vue | 35 +++-------- .../components/popularity/github-mentions.vue | 24 ++------ .../components/popularity/press-mentions.vue | 18 ++---- .../components/popularity/social-mentions.vue | 24 ++------ .../project/components/popularity/stars.vue | 35 +++-------- .../popularity/types/mentions.types.ts | 2 +- .../popularity/types/popularity.types.ts | 2 +- .../types/delta-display.types.ts | 2 +- .../types => types/shared}/summary.types.ts | 0 28 files changed, 116 insertions(+), 406 deletions(-) rename frontend/{app/components/shared/types => types/shared}/summary.types.ts (100%) diff --git a/frontend/app/components/modules/project/components/contributors/active-contributors.vue b/frontend/app/components/modules/project/components/contributors/active-contributors.vue index f92a7028e..c8b402576 100644 --- a/frontend/app/components/modules/project/components/contributors/active-contributors.vue +++ b/frontend/app/components/modules/project/components/contributors/active-contributors.vue @@ -8,34 +8,17 @@
- +
{{ formatNumber(summary.current) }}
- +
- - + +
@@ -50,7 +33,7 @@ import LfxProjectLoadState from '../shared/load-state.vue'; import LfxSkeletonState from '../shared/skeleton-state.vue'; import type { ActiveContributors } from './types/contributors.types'; import { granularityTabs } from './config/granularity-tabs'; -import type { Summary } from '~/components/shared/types/summary.types'; +import type { Summary } from '~~/types/shared/summary.types'; import LfxCard from '~/components/uikit/card/card.vue'; import LfxDeltaDisplay from '~/components/uikit/delta-display/delta-display.vue'; import LfxTabs from '~/components/uikit/tabs/tabs.vue'; diff --git a/frontend/app/components/modules/project/components/contributors/active-organizations.vue b/frontend/app/components/modules/project/components/contributors/active-organizations.vue index e21c4bb9e..03c985072 100644 --- a/frontend/app/components/modules/project/components/contributors/active-organizations.vue +++ b/frontend/app/components/modules/project/components/contributors/active-organizations.vue @@ -8,34 +8,17 @@
- +
{{ formatNumber(summary.current) }}
- +
- - + +
@@ -50,7 +33,7 @@ import LfxProjectLoadState from '../shared/load-state.vue'; import LfxSkeletonState from '../shared/skeleton-state.vue'; import type { ActiveOrganizations } from './types/contributors.types'; import { granularityTabs } from './config/granularity-tabs'; -import type { Summary } from '~/components/shared/types/summary.types'; +import type { Summary } from '~~/types/shared/summary.types'; import LfxCard from '~/components/uikit/card/card.vue'; import LfxDeltaDisplay from '~/components/uikit/delta-display/delta-display.vue'; import LfxTabs from '~/components/uikit/tabs/tabs.vue'; diff --git a/frontend/app/components/modules/project/components/contributors/types/contributors.types.ts b/frontend/app/components/modules/project/components/contributors/types/contributors.types.ts index 849eaac40..d429c7d0f 100644 --- a/frontend/app/components/modules/project/components/contributors/types/contributors.types.ts +++ b/frontend/app/components/modules/project/components/contributors/types/contributors.types.ts @@ -1,4 +1,4 @@ -import type { Summary } from '~/components/shared/types/summary.types'; +import type { Summary } from '~~/types/shared/summary.types'; export interface ActiveContributors { summary: Summary; diff --git a/frontend/app/components/modules/project/components/development/active-days.vue b/frontend/app/components/modules/project/components/development/active-days.vue index 72f4f6148..350be4298 100644 --- a/frontend/app/components/modules/project/components/development/active-days.vue +++ b/frontend/app/components/modules/project/components/development/active-days.vue @@ -11,33 +11,18 @@
- +
{{ formatNumber(summary.current) }}
- +
-
+
Avg. contributions per day - + {{ formatNumber(activeDays.avgContributions) }} @@ -47,14 +32,8 @@
Contributions per day
- +
@@ -70,7 +49,7 @@ import { storeToRefs } from "pinia"; import LfxProjectLoadState from '../shared/load-state.vue'; import LfxSkeletonState from '../shared/skeleton-state.vue'; import type { ActiveDays } from './types/active-days.types'; -import type { Summary } from '~/components/shared/types/summary.types'; +import type { Summary } from '~~/types/shared/summary.types'; import LfxCard from '~/components/uikit/card/card.vue'; import LfxDeltaDisplay from '~/components/uikit/delta-display/delta-display.vue'; import { convertToChartData, convertToCategoryData } from '~/components/uikit/chart/helpers/chart-helpers'; diff --git a/frontend/app/components/modules/project/components/development/average-time-to-merge.vue b/frontend/app/components/modules/project/components/development/average-time-to-merge.vue index c766a2ebf..ddefab080 100644 --- a/frontend/app/components/modules/project/components/development/average-time-to-merge.vue +++ b/frontend/app/components/modules/project/components/development/average-time-to-merge.vue @@ -10,31 +10,16 @@
- +
{{ formatNumberToDuration(summary.current) }}
- +
- +
@@ -50,7 +35,7 @@ import { storeToRefs } from "pinia"; import LfxProjectLoadState from '../shared/load-state.vue'; import LfxSkeletonState from '../shared/skeleton-state.vue'; import type { AverageTimeMerge } from './types/average-time-merge.types'; -import type { Summary } from '~/components/shared/types/summary.types'; +import type { Summary } from '~~/types/shared/summary.types'; import LfxCard from '~/components/uikit/card/card.vue'; import LfxDeltaDisplay from '~/components/uikit/delta-display/delta-display.vue'; import { convertToChartData } from '~/components/uikit/chart/helpers/chart-helpers'; diff --git a/frontend/app/components/modules/project/components/development/code-review-engagement.vue b/frontend/app/components/modules/project/components/development/code-review-engagement.vue index 5d0b5ebaf..22ce3f630 100644 --- a/frontend/app/components/modules/project/components/development/code-review-engagement.vue +++ b/frontend/app/components/modules/project/components/development/code-review-engagement.vue @@ -9,45 +9,23 @@


- +
- +
{{ formatNumber(summary.current) }} contributors
- +
- +
Top contributors
- +
@@ -62,7 +40,7 @@ import LfxProjectLoadState from '../shared/load-state.vue'; import LfxSkeletonState from '../shared/skeleton-state.vue'; import type { CodeReviewEngagement } from './types/code-review-engagement.types'; import LfxCodeReviewTable from './fragments/code-review-table.vue'; -import type { Summary } from '~/components/shared/types/summary.types'; +import type { Summary } from '~~/types/shared/summary.types'; import LfxCard from '~/components/uikit/card/card.vue'; import LfxDeltaDisplay from '~/components/uikit/delta-display/delta-display.vue'; import LfxTabs from '~/components/uikit/tabs/tabs.vue'; diff --git a/frontend/app/components/modules/project/components/development/contributions-outside-work-hours.vue b/frontend/app/components/modules/project/components/development/contributions-outside-work-hours.vue index 3b0a67147..fc5ee1feb 100644 --- a/frontend/app/components/modules/project/components/development/contributions-outside-work-hours.vue +++ b/frontend/app/components/modules/project/components/development/contributions-outside-work-hours.vue @@ -10,20 +10,11 @@
- +
{{ formatNumber(summary.current) }}%
- +
@@ -31,15 +22,8 @@ Mon-Fri (after 18:00) - - + + {{ formatNumber(weekdayPercentage, 1) }}% @@ -48,29 +32,16 @@ Weekends - - + + {{ formatNumber(weekendPercentage, 1) }}%
- +
@@ -86,7 +57,7 @@ import { storeToRefs } from "pinia"; import LfxProjectLoadState from '../shared/load-state.vue'; import LfxSkeletonState from '../shared/skeleton-state.vue'; import type { ContributionOutsideHours } from './types/contribution-outside-hours.types'; -import type { Summary } from '~/components/shared/types/summary.types'; +import type { Summary } from '~~/types/shared/summary.types'; import LfxCard from '~/components/uikit/card/card.vue'; import LfxDeltaDisplay from '~/components/uikit/delta-display/delta-display.vue'; import { convertToChartData } from '~/components/uikit/chart/helpers/chart-helpers'; diff --git a/frontend/app/components/modules/project/components/development/fragments/pull-request-legend-item.vue b/frontend/app/components/modules/project/components/development/fragments/pull-request-legend-item.vue index 61f24c8a0..694cd875a 100644 --- a/frontend/app/components/modules/project/components/development/fragments/pull-request-legend-item.vue +++ b/frontend/app/components/modules/project/components/development/fragments/pull-request-legend-item.vue @@ -1,29 +1,20 @@