Skip to content

Commit

Permalink
feat(result): add duplicated submissions count
Browse files Browse the repository at this point in the history
  • Loading branch information
angristan committed Jul 28, 2021
1 parent 0bab2e7 commit 773e22d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/Benchmarks/BenchmarkDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ const BenchmarkDetail = ({
lintScore={jobData.lintScore}
lintErrors={jobData.lintErrors}
isLoading={isProcessing}
maxCyclomaticComplexity={benchmarkData?.maxCyclomaticComplexity}
maxCyclomaticComplexity={benchmarkData?.maxCyclomaticComplexity ?? 10}
duplicatedSubmissions={jobData.duplicatedSubmissions}
/>
);
}
Expand Down
18 changes: 18 additions & 0 deletions src/components/Benchmarks/Result.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import Loader from 'react-loader-spinner';
import { LintErrorDTO } from '../../api/dto/lint-error.dto';
import { SubmissionDTO } from './submission.dto';
interface LayoutProps {
status: string;
message: string;
Expand All @@ -15,6 +16,7 @@ interface LayoutProps {
lintErrors?: LintErrorDTO[];
isLoading: boolean;
maxCyclomaticComplexity?: number;
duplicatedSubmissions?: SubmissionDTO[];
}

const Result: React.FC<LayoutProps> = ({
Expand All @@ -31,6 +33,7 @@ const Result: React.FC<LayoutProps> = ({
isLoading,
cyclomaticComplexity,
maxCyclomaticComplexity,
duplicatedSubmissions,
}) => {
if (status !== 'done' && status !== 'failed') {
return (
Expand All @@ -56,6 +59,7 @@ const Result: React.FC<LayoutProps> = ({
execDuration={execDuration}
cyclomaticComplexity={cyclomaticComplexity}
maxCyclomaticComplexity={maxCyclomaticComplexity}
duplicatedSubmissions={duplicatedSubmissions}
/>
</div>
<div className="w-3/5 pl-6">
Expand Down Expand Up @@ -143,6 +147,7 @@ interface ScoresComponentProps {
execDuration: number | undefined;
cyclomaticComplexity: number | undefined;
maxCyclomaticComplexity: number | undefined;
duplicatedSubmissions: SubmissionDTO[] | undefined;
}

const ScoresComponent: React.FC<ScoresComponentProps> = ({
Expand All @@ -153,6 +158,7 @@ const ScoresComponent: React.FC<ScoresComponentProps> = ({
execDuration,
cyclomaticComplexity,
maxCyclomaticComplexity,
duplicatedSubmissions,
}) => {
return (
<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">
Expand Down Expand Up @@ -251,6 +257,18 @@ const ScoresComponent: React.FC<ScoresComponentProps> = ({
</div>
</td>
</tr>
<tr className="text-gray-700 dark:text-gray-100">
<th className="border-t-0 px-4 align-middle border-l-0 border-r-0 text-sm whitespace-nowrap p-3 text-left">
Duplicate submissions
</th>
<td className="border-t-0 px-4 align-middle border-l-0 border-r-0 text-sm whitespace-nowrap p-3">
<div className="flex items-center">
<span className="mr-2">
{duplicatedSubmissions?.length}{' '}
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
Expand Down
29 changes: 29 additions & 0 deletions src/components/Benchmarks/submission.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export interface SubmissionDTO {
id: string;
language: string;
code: string;
codeHash: string;
status: string;
stdout?: string;
stderr?: string;
message?: string;
error?: string;
execDuration: number;
memUsage: number;
createdAt: Date;
updatedAt: Date;
lintScore: number;
qualityScore: number;
cyclomaticComplexity: number;
user: User;
duplicatedSubmissions?: SubmissionDTO[];
}

export interface User {
id: string;
name: string;
username: string;
email: string;
createdAt: Date;
updatedAt: Date;
}
2 changes: 2 additions & 0 deletions src/hooks/submissions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from 'react';
import { useMutation, useQuery } from 'react-query';
import { LintErrorDTO } from '../api/dto/lint-error.dto';
import { SubmissionDTO } from '../components/Benchmarks/submission.dto';
import authenticatedRequest from '../components/utils/request';
import { useToken } from './token';

Expand Down Expand Up @@ -69,6 +70,7 @@ function useProcessInterval({
cyclomaticComplexity: number;
lintScore: number;
lintErrors?: LintErrorDTO[];
duplicatedSubmissions: SubmissionDTO[];
};
} = await authenticatedRequest({
url: `submissions/${processId}`,
Expand Down

0 comments on commit 773e22d

Please sign in to comment.