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: community report data filter #232

Merged
merged 5 commits into from
Sep 13, 2023
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
27 changes: 22 additions & 5 deletions apps/web/src/modules/analyze/context/ChartsDataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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: {
Expand All @@ -41,14 +41,21 @@ export const ChartsDataContext = createContext<typeof dataState>(dataState);

const ChartsDataProvider: React.FC<PropsWithChildren> = ({ 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),
Expand All @@ -68,7 +75,13 @@ const ChartsDataProvider: React.FC<PropsWithChildren> = ({ 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,
Expand All @@ -91,6 +104,10 @@ const ChartsDataProvider: React.FC<PropsWithChildren> = ({ children }) => {
}
}, [isLoading, items, proxyState]);

// useEffect(() => {
// rType = ;
// }, [snap.repoType]);

return (
<ChartsDataContext.Provider value={proxyState}>
{children}
Expand Down
25 changes: 22 additions & 3 deletions packages/graphql/src/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1408,27 +1408,31 @@ export type QueryMetricActivityArgs = {
endDate?: InputMaybe<Scalars['ISO8601DateTime']>;
label: Scalars['String'];
level?: InputMaybe<Scalars['String']>;
repoType?: InputMaybe<Scalars['String']>;
};

export type QueryMetricCodequalityArgs = {
beginDate?: InputMaybe<Scalars['ISO8601DateTime']>;
endDate?: InputMaybe<Scalars['ISO8601DateTime']>;
label: Scalars['String'];
level?: InputMaybe<Scalars['String']>;
repoType?: InputMaybe<Scalars['String']>;
};

export type QueryMetricCommunityArgs = {
beginDate?: InputMaybe<Scalars['ISO8601DateTime']>;
endDate?: InputMaybe<Scalars['ISO8601DateTime']>;
label: Scalars['String'];
level?: InputMaybe<Scalars['String']>;
repoType?: InputMaybe<Scalars['String']>;
};

export type QueryMetricGroupActivityArgs = {
beginDate?: InputMaybe<Scalars['ISO8601DateTime']>;
endDate?: InputMaybe<Scalars['ISO8601DateTime']>;
label: Scalars['String'];
level?: InputMaybe<Scalars['String']>;
repoType?: InputMaybe<Scalars['String']>;
};

export type QueryMetricStarterProjectHealthArgs = {
Expand Down Expand Up @@ -3421,6 +3425,7 @@ export type MetricQueryVariables = Exact<{
level?: InputMaybe<Scalars['String']>;
start?: InputMaybe<Scalars['ISO8601DateTime']>;
end?: InputMaybe<Scalars['ISO8601DateTime']>;
repoType?: InputMaybe<Scalars['String']>;
}>;

export type MetricQuery = {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -6529,6 +6547,7 @@ export const MetricDocument = /*#__PURE__*/ `
level: $level
beginDate: $start
endDate: $end
repoType: $repoType
) {
commitFrequency
contributionLast
Expand Down
5 changes: 5 additions & 0 deletions packages/graphql/src/gql/query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -141,6 +143,7 @@ query metric(
level: $level
beginDate: $start
endDate: $end
repoType: $repoType
) {
bugIssueOpenTimeAvg
bugIssueOpenTimeMid
Expand All @@ -166,6 +169,7 @@ query metric(
level: $level
beginDate: $start
endDate: $end
repoType: $repoType
) {
activeC1IssueCommentsContributorCount
activeC1IssueCreateContributorCount
Expand Down Expand Up @@ -193,6 +197,7 @@ query metric(
level: $level
beginDate: $start
endDate: $end
repoType: $repoType
) {
commitFrequency
# commitFrequencyOrg
Expand Down