-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into t734-implements-test-api
- Loading branch information
Showing
50 changed files
with
2,113 additions
and
1,072 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/mocharc", | ||
"extension": "spec.ts", | ||
"require": [ | ||
"ts-node/register/transpile-only", | ||
"tsconfig-paths/register", | ||
"./mocha-fixture.ts" | ||
], | ||
"require": ["@swc-node/register", "./mocha-fixture.ts"], | ||
"reporter": "dot" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const swcDefaultConfig = | ||
require('@nestjs/cli/lib/compiler/defaults/swc-defaults').swcDefaultsFactory() | ||
.swcOptions | ||
|
||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'swc-loader', | ||
options: swcDefaultConfig | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
import { fetcherWithAuth } from '@/lib/utils' | ||
import { safeFetcherWithAuth } from '@/lib/utils' | ||
import type { ContestProblem } from '@/types/type' | ||
|
||
interface ContestProblemsApiRes { | ||
data: ContestProblem[] | ||
} | ||
|
||
const calculateContestScore = async ({ contestId }: { contestId: string }) => { | ||
const contestProblems: ContestProblemsApiRes = await fetcherWithAuth | ||
.get(`contest/${contestId}/problem`) | ||
.json() | ||
try { | ||
const contestProblems: ContestProblemsApiRes = await safeFetcherWithAuth | ||
.get(`contest/${contestId}/problem`) | ||
.json() | ||
|
||
const { totalScore, totalMaxScore } = contestProblems.data.reduce( | ||
(acc, curr) => { | ||
const score = curr.score ? parseInt(curr.score, 10) : 0 | ||
const maxScore = curr.maxScore || 0 | ||
const { totalScore, totalMaxScore } = contestProblems.data.reduce( | ||
(acc, curr) => { | ||
const score = curr.score ? parseInt(curr.score, 10) : 0 | ||
const maxScore = curr.maxScore || 0 | ||
|
||
acc.totalScore += score | ||
acc.totalMaxScore += maxScore | ||
acc.totalScore += score | ||
acc.totalMaxScore += maxScore | ||
|
||
return acc | ||
}, | ||
{ totalScore: 0, totalMaxScore: 0 } | ||
) | ||
return [totalScore, totalMaxScore] | ||
return acc | ||
}, | ||
{ totalScore: 0, totalMaxScore: 0 } | ||
) | ||
return [totalScore, totalMaxScore] | ||
} catch (error) { | ||
return [0, 0] | ||
} | ||
} | ||
|
||
export { calculateContestScore } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.