Skip to content

Commit

Permalink
feat
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed Feb 23, 2024
1 parent d66f22a commit e4f004d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/canyon-backend/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Project {

type BuOption {
bu: String!
count: Float!
}

type ProjectPagesModel {
Expand Down
2 changes: 2 additions & 0 deletions packages/canyon-backend/src/project/project.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ export class Project {
export class BuOption {
@Field(() => String)
bu: string;
@Field(() => Number)
count: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export class GetProjectsService {
return {
id: id,
bu: project.bu,
description: project.description,
lastReportTime:
summarys.length > 0
? summarys[0].createdAt
Expand Down
16 changes: 13 additions & 3 deletions packages/canyon-backend/src/project/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,18 @@ export class ProjectService {
}

async getProjectsBuOptions() {
return this.prisma.project.groupBy({
by: ['bu'],
});
return this.prisma.project
.groupBy({
by: ['bu'],
_count: true,
})
.then((res) => {
return res.map((item) => {
return {
bu: item.bu,
count: item._count,
};
});
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ query GetProjects($current: Int!, $pageSize: Int!, $keyword: String!,$bu: [Strin
data {
id
pathWithNamespace
description
bu
reportTimes
lastReportTime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
query GetProjectsBuOptions {
getProjectsBuOptions {
bu
bu,
count
}
}
17 changes: 14 additions & 3 deletions packages/canyon-platform/src/pages/index/projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
Project,
} from '../../../helpers/backend/gen/graphql.ts';

const { Title } = Typography;
const { Title, Text } = Typography;

const { useToken } = theme;
const ProjectPage = () => {
Expand All @@ -33,6 +33,16 @@ const ProjectPage = () => {
title: t('projects.name'),
dataIndex: 'pathWithNamespace',
key: 'pathWithNamespace',
render: (text, record) => {
return (
<div className={'flex flex-col'}>
{text}
<Text type={'secondary'} style={{ fontSize: '12px' }}>
{record.description}
</Text>
</div>
);
},
},
{
title: 'Bu',
Expand Down Expand Up @@ -172,8 +182,8 @@ const ProjectPage = () => {
}}
placeholder={'Bu'}
className={'w-[200px] mr-2'}
options={(projectsBuOptionsData?.getProjectsBuOptions || []).map(({ bu }) => ({
label: bu,
options={(projectsBuOptionsData?.getProjectsBuOptions || []).map(({ bu, count }) => ({
label: bu + ` ${count}`,
value: bu,
}))}
/>
Expand Down Expand Up @@ -206,6 +216,7 @@ const ProjectPage = () => {
}}
bordered={false}
dataSource={projectsData?.getProjects?.data || []}
// @ts-ignore
columns={columns}
onChange={(val, _, _sorter: any) => {
setSorter({
Expand Down

0 comments on commit e4f004d

Please sign in to comment.