Skip to content

Commit 773e22d

Browse files
committed
feat(result): add duplicated submissions count
1 parent 0bab2e7 commit 773e22d

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

src/components/Benchmarks/BenchmarkDetail.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ const BenchmarkDetail = ({
9696
lintScore={jobData.lintScore}
9797
lintErrors={jobData.lintErrors}
9898
isLoading={isProcessing}
99-
maxCyclomaticComplexity={benchmarkData?.maxCyclomaticComplexity}
99+
maxCyclomaticComplexity={benchmarkData?.maxCyclomaticComplexity ?? 10}
100+
duplicatedSubmissions={jobData.duplicatedSubmissions}
100101
/>
101102
);
102103
}

src/components/Benchmarks/Result.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import Loader from 'react-loader-spinner';
33
import { LintErrorDTO } from '../../api/dto/lint-error.dto';
4+
import { SubmissionDTO } from './submission.dto';
45
interface LayoutProps {
56
status: string;
67
message: string;
@@ -15,6 +16,7 @@ interface LayoutProps {
1516
lintErrors?: LintErrorDTO[];
1617
isLoading: boolean;
1718
maxCyclomaticComplexity?: number;
19+
duplicatedSubmissions?: SubmissionDTO[];
1820
}
1921

2022
const Result: React.FC<LayoutProps> = ({
@@ -31,6 +33,7 @@ const Result: React.FC<LayoutProps> = ({
3133
isLoading,
3234
cyclomaticComplexity,
3335
maxCyclomaticComplexity,
36+
duplicatedSubmissions,
3437
}) => {
3538
if (status !== 'done' && status !== 'failed') {
3639
return (
@@ -56,6 +59,7 @@ const Result: React.FC<LayoutProps> = ({
5659
execDuration={execDuration}
5760
cyclomaticComplexity={cyclomaticComplexity}
5861
maxCyclomaticComplexity={maxCyclomaticComplexity}
62+
duplicatedSubmissions={duplicatedSubmissions}
5963
/>
6064
</div>
6165
<div className="w-3/5 pl-6">
@@ -143,6 +147,7 @@ interface ScoresComponentProps {
143147
execDuration: number | undefined;
144148
cyclomaticComplexity: number | undefined;
145149
maxCyclomaticComplexity: number | undefined;
150+
duplicatedSubmissions: SubmissionDTO[] | undefined;
146151
}
147152

148153
const ScoresComponent: React.FC<ScoresComponentProps> = ({
@@ -153,6 +158,7 @@ const ScoresComponent: React.FC<ScoresComponentProps> = ({
153158
execDuration,
154159
cyclomaticComplexity,
155160
maxCyclomaticComplexity,
161+
duplicatedSubmissions,
156162
}) => {
157163
return (
158164
<div className="relative flex flex-col min-w-0 mb-4 lg:mb-0 break-words bg-gray-50 dark:bg-gray-800 w-full shadow-lg rounded">
@@ -251,6 +257,18 @@ const ScoresComponent: React.FC<ScoresComponentProps> = ({
251257
</div>
252258
</td>
253259
</tr>
260+
<tr className="text-gray-700 dark:text-gray-100">
261+
<th className="border-t-0 px-4 align-middle border-l-0 border-r-0 text-sm whitespace-nowrap p-3 text-left">
262+
Duplicate submissions
263+
</th>
264+
<td className="border-t-0 px-4 align-middle border-l-0 border-r-0 text-sm whitespace-nowrap p-3">
265+
<div className="flex items-center">
266+
<span className="mr-2">
267+
{duplicatedSubmissions?.length}{' '}
268+
</span>
269+
</div>
270+
</td>
271+
</tr>
254272
</tbody>
255273
</table>
256274
</div>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export interface SubmissionDTO {
2+
id: string;
3+
language: string;
4+
code: string;
5+
codeHash: string;
6+
status: string;
7+
stdout?: string;
8+
stderr?: string;
9+
message?: string;
10+
error?: string;
11+
execDuration: number;
12+
memUsage: number;
13+
createdAt: Date;
14+
updatedAt: Date;
15+
lintScore: number;
16+
qualityScore: number;
17+
cyclomaticComplexity: number;
18+
user: User;
19+
duplicatedSubmissions?: SubmissionDTO[];
20+
}
21+
22+
export interface User {
23+
id: string;
24+
name: string;
25+
username: string;
26+
email: string;
27+
createdAt: Date;
28+
updatedAt: Date;
29+
}

src/hooks/submissions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useState } from 'react';
22
import { useMutation, useQuery } from 'react-query';
33
import { LintErrorDTO } from '../api/dto/lint-error.dto';
4+
import { SubmissionDTO } from '../components/Benchmarks/submission.dto';
45
import authenticatedRequest from '../components/utils/request';
56
import { useToken } from './token';
67

@@ -69,6 +70,7 @@ function useProcessInterval({
6970
cyclomaticComplexity: number;
7071
lintScore: number;
7172
lintErrors?: LintErrorDTO[];
73+
duplicatedSubmissions: SubmissionDTO[];
7274
};
7375
} = await authenticatedRequest({
7476
url: `submissions/${processId}`,

0 commit comments

Comments
 (0)