From 91efe56ddb0e47f3c4ef1be8a90941c86fde03a2 Mon Sep 17 00:00:00 2001 From: laixingyou Date: Wed, 13 Sep 2023 17:55:08 +0800 Subject: [PATCH] feat: community report data filter (#232) Signed-off-by: laixingyou --- .../analyze/context/ChartsDataProvider.tsx | 27 +++++++++++++++---- packages/graphql/src/generated.ts | 25 ++++++++++++++--- packages/graphql/src/gql/query.graphql | 5 ++++ 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/apps/web/src/modules/analyze/context/ChartsDataProvider.tsx b/apps/web/src/modules/analyze/context/ChartsDataProvider.tsx index 5be28ca5..5b77832f 100644 --- a/apps/web/src/modules/analyze/context/ChartsDataProvider.tsx +++ b/apps/web/src/modules/analyze/context/ChartsDataProvider.tsx @@ -4,7 +4,7 @@ import React, { useRef, createContext, } from 'react'; -import { proxy } from 'valtio'; +import { proxy, useSnapshot } from 'valtio'; import useQueryDateRange from '@modules/analyze/hooks/useQueryDateRange'; import useCompareItems from '@modules/analyze/hooks/useCompareItems'; import usePageLoadHashScroll from '@common/hooks/usePageLoadHashScroll'; @@ -17,7 +17,7 @@ import { } from '@oss-compass/graphql'; import client from '@common/gqlClient'; import { Level } from '@modules/analyze/constant'; - +import { chartUserSettingState } from '@modules/analyze/store'; interface Store { loading: boolean; items: { @@ -41,14 +41,21 @@ export const ChartsDataContext = createContext(dataState); const ChartsDataProvider: React.FC = ({ children }) => { const proxyState = useRef(dataState).current; - + const snap = useSnapshot(chartUserSettingState); + const repoType = snap.repoType; const queryClient = useQueryClient(); const { timeStart, timeEnd } = useQueryDateRange(); const { compareItems } = useCompareItems(); useQueries({ queries: compareItems.map(({ label, level }) => { - const variables = { label, level, start: timeStart, end: timeEnd }; + const variables = { + label, + level, + start: timeStart, + end: timeEnd, + repoType: repoType, + }; return { queryKey: useMetricQuery.getKey(variables), queryFn: useMetricQuery.fetcher(client, variables), @@ -68,7 +75,13 @@ const ChartsDataProvider: React.FC = ({ children }) => { const items = compareItems .map(({ label, level }) => { - const variables = { label, level, start: timeStart, end: timeEnd }; + const variables = { + label, + level, + start: timeStart, + end: timeEnd, + repoType: repoType, + }; const key = useMetricQuery.getKey(variables); return { label, @@ -91,6 +104,10 @@ const ChartsDataProvider: React.FC = ({ children }) => { } }, [isLoading, items, proxyState]); + // useEffect(() => { + // rType = ; + // }, [snap.repoType]); + return ( {children} diff --git a/packages/graphql/src/generated.ts b/packages/graphql/src/generated.ts index 8095b063..9cf72a36 100644 --- a/packages/graphql/src/generated.ts +++ b/packages/graphql/src/generated.ts @@ -1408,6 +1408,7 @@ export type QueryMetricActivityArgs = { endDate?: InputMaybe; label: Scalars['String']; level?: InputMaybe; + repoType?: InputMaybe; }; export type QueryMetricCodequalityArgs = { @@ -1415,6 +1416,7 @@ export type QueryMetricCodequalityArgs = { endDate?: InputMaybe; label: Scalars['String']; level?: InputMaybe; + repoType?: InputMaybe; }; export type QueryMetricCommunityArgs = { @@ -1422,6 +1424,7 @@ export type QueryMetricCommunityArgs = { endDate?: InputMaybe; label: Scalars['String']; level?: InputMaybe; + repoType?: InputMaybe; }; export type QueryMetricGroupActivityArgs = { @@ -1429,6 +1432,7 @@ export type QueryMetricGroupActivityArgs = { endDate?: InputMaybe; label: Scalars['String']; level?: InputMaybe; + repoType?: InputMaybe; }; export type QueryMetricStarterProjectHealthArgs = { @@ -3421,6 +3425,7 @@ export type MetricQueryVariables = Exact<{ level?: InputMaybe; start?: InputMaybe; end?: InputMaybe; + repoType?: InputMaybe; }>; export type MetricQuery = { @@ -6448,12 +6453,13 @@ useCommunityReposQuery.fetcher = ( headers ); export const MetricDocument = /*#__PURE__*/ ` - query metric($label: String!, $level: String = "repo", $start: ISO8601DateTime, $end: ISO8601DateTime) { + query metric($label: String!, $level: String = "repo", $start: ISO8601DateTime, $end: ISO8601DateTime, $repoType: String) { metricCodequality( label: $label level: $level beginDate: $start endDate: $end + repoType: $repoType ) { activeC1PrCommentsContributorCount activeC1PrCreateContributorCount @@ -6482,7 +6488,13 @@ export const MetricDocument = /*#__PURE__*/ ` prIssueLinkedCount prIssueLinkedRatio } - metricCommunity(label: $label, level: $level, beginDate: $start, endDate: $end) { + metricCommunity( + label: $label + level: $level + beginDate: $start + endDate: $end + repoType: $repoType + ) { bugIssueOpenTimeAvg bugIssueOpenTimeMid closedPrsCount @@ -6502,7 +6514,13 @@ export const MetricDocument = /*#__PURE__*/ ` prOpenTimeMid updatedIssuesCount } - metricActivity(label: $label, level: $level, beginDate: $start, endDate: $end) { + metricActivity( + label: $label + level: $level + beginDate: $start + endDate: $end + repoType: $repoType + ) { activeC1IssueCommentsContributorCount activeC1IssueCreateContributorCount activeC1PrCommentsContributorCount @@ -6529,6 +6547,7 @@ export const MetricDocument = /*#__PURE__*/ ` level: $level beginDate: $start endDate: $end + repoType: $repoType ) { commitFrequency contributionLast diff --git a/packages/graphql/src/gql/query.graphql b/packages/graphql/src/gql/query.graphql index d7a77d0a..24944f44 100644 --- a/packages/graphql/src/gql/query.graphql +++ b/packages/graphql/src/gql/query.graphql @@ -102,12 +102,14 @@ query metric( $level: String = "repo" $start: ISO8601DateTime $end: ISO8601DateTime + $repoType: String ) { metricCodequality( label: $label level: $level beginDate: $start endDate: $end + repoType: $repoType ) { activeC1PrCommentsContributorCount activeC1PrCreateContributorCount @@ -141,6 +143,7 @@ query metric( level: $level beginDate: $start endDate: $end + repoType: $repoType ) { bugIssueOpenTimeAvg bugIssueOpenTimeMid @@ -166,6 +169,7 @@ query metric( level: $level beginDate: $start endDate: $end + repoType: $repoType ) { activeC1IssueCommentsContributorCount activeC1IssueCreateContributorCount @@ -193,6 +197,7 @@ query metric( level: $level beginDate: $start endDate: $end + repoType: $repoType ) { commitFrequency # commitFrequencyOrg