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

2024 changes #300

Closed
wants to merge 3 commits into from
Closed
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
Empty file modified .docker/Dockerfile.mongo
100644 → 100755
Empty file.
10 changes: 6 additions & 4 deletions .docker/init-mongo.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ db.createUser({
user: "username",
pwd: "password",
roles: [{
role: "readWrite",
db: "abacus"
}]
role: "dbAdmin",
db: "abacus"},
{role: "readWrite",
db: "abacus"}
]
})

db.createCollection('user')

db.user.insert({
uid: "b126d7588b184db7818693c2ab891887",
display_name: "Admin",
password: "65df4b1116b849b2d02063932b1472a2c15545908d2bdb029c14bd710158c1e2",
password: "62b5f0bf8345c5c47ededf67c6a205131b1fa2d0c07e5e3f747395285780cccf",
role: "admin",
username: "admin"
})
Expand Down
Empty file modified .github/ISSUE_TEMPLATE/bug_report.md
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/config.yml
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/documentation.md
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/feature_request.md
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/question.md
100644 → 100755
Empty file.
Empty file modified .github/PULL_REQUEST_TEMPLATE.md
100644 → 100755
Empty file.
Empty file modified .github/disabled_workflows/DeployAbacusApp.yml
100644 → 100755
Empty file.
Empty file modified .github/disabled_workflows/DeployPistonRunner.yml
100644 → 100755
Empty file.
Empty file modified .github/disabled_workflows/DeployReactApp.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/ci-eslint-backend.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/ci-eslint-frontend.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/ci-prettier.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/ci-test-backend.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/ci-test-frontend.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/deploy-backend-docker.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/deploy-frontend-docker.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .prettierrc.js
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions abacus
Submodule abacus added at 0f61e9
Empty file modified backend/.dockerignore
100644 → 100755
Empty file.
Empty file modified backend/.env
100644 → 100755
Empty file.
Empty file modified backend/.eslintrc.json
100644 → 100755
Empty file.
Empty file modified backend/.prettierignore
100644 → 100755
Empty file.
22 changes: 17 additions & 5 deletions backend/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# pull official base image
FROM node:16

ENV CHOKIDAR_USEPOLLING true
FROM node:16 as build

# set working directory
WORKDIR /app
Expand All @@ -15,7 +13,21 @@ RUN yarn global add nodemon --silent
# add app
COPY . ./

# production environment
FROM build as production

# add `/app/node_modules/.bin` to PATH
ENV PATH /app/node_modules/.bin:$PATH
ENV NODE_OPTIONS=--MAX-OLD-SPACE-SIZE=10240
# build app
RUN yarn build

EXPOSE 80

# run development server
CMD ["yarn", "dev"]
# start app
CMD ["node", "/app/build/server.js"]



# build container: docker build -f Dockerfile.prod -t abacus-server:prod .
# run container: docker run -it --rm -p 80:80 abacus-server:prod
Empty file modified backend/Dockerfile.prod
100644 → 100755
Empty file.
Empty file modified backend/README.md
100644 → 100755
Empty file.
Empty file modified backend/package.json
100644 → 100755
Empty file.
Empty file modified backend/src/@types/abacus/index.d.ts
100644 → 100755
Empty file.
Empty file modified backend/src/@types/express/index.d.ts
100644 → 100755
Empty file.
Empty file modified backend/src/abacus/authlib.ts
100644 → 100755
Empty file.
Empty file modified backend/src/abacus/contest.ts
100644 → 100755
Empty file.
Empty file modified backend/src/abacus/index.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/auth/getAuth.ts
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion backend/src/api/auth/getTableSize.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const getTableSize = async (req: Request, res: Response) => {
const tableSize = await contest.get_table_size(tableName, params)
//divides by the number of items per page.

const pages = tableSize ? tableSize / 25 : 0
const pages = tableSize ? tableSize : 0
//send response back.
res.send({ tableSize: pages })
} else {
Expand Down
Empty file modified backend/src/api/auth/index.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/auth/postAuth.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/clarifications/deleteClarifications.ts
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion backend/src/api/clarifications/getClarifications.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const getClarifications = async (req: Request, res: Response): Promise<vo

res.send(map)
} catch (err) {
console.error(err)
//console.error(err)
res.sendStatus(500)
}
}
Empty file modified backend/src/api/clarifications/index.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/clarifications/postClarifications.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/clarifications/putClarifications.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/contest/getContest.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/contest/index.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/contest/putContest.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/index.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/problems/deleteProblems.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/problems/downloadFiles.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/problems/getProblems.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/problems/index.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/problems/postProblems.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/problems/putProblems.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/scratch/getProject.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/scratch/getUser.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/scratch/index.ts
100644 → 100755
Empty file.
3 changes: 0 additions & 3 deletions backend/src/api/standings/getStandings.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,11 @@ const getGoldStandings = async (isPractice: boolean): Promise<Standings<GoldTeam
'max_points',
'capped_points'
])
console.log('problemsLift before', problemsList)
problemsList = problemsList.filter(({ practice }) => {
if (isPractice) return practice
return practice == undefined || practice == false
})

console.log('problemsLift after', problemsList)

const problems = transpose(problemsList, 'pid')

const subs: Record<string, Record<string, Submission[]>> = {}
Expand Down
Empty file modified backend/src/api/standings/index.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/submissions/deleteSubmissions.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/submissions/getSubmissions.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/submissions/index.ts
100644 → 100755
Empty file.
26 changes: 14 additions & 12 deletions backend/src/api/submissions/postSubmissions.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ export const postSubmissions = async (req: Request, res: Response): Promise<void
res.status(403).send({ message: 'You can not submit to problems in this division!' })
return
}

/*points_per_yes,
points_per_minute,
points_per_no*/
const {
start_date,
end_date,
practice_start_date,
practice_end_date,
points_per_yes,
points_per_minute,
points_per_no

} = await contest.get_settings()
const now = Date.now()
if (problem.practice) {
Expand Down Expand Up @@ -215,7 +215,7 @@ export const postSubmissions = async (req: Request, res: Response): Promise<void
source: data.toString('utf-8')
}
let status = 'accepted'
for (let test of problem.tests) {
/*for (let test of problem.tests) {
// Copy tests from problem
submission.tests = problem.tests

Expand All @@ -224,11 +224,12 @@ export const postSubmissions = async (req: Request, res: Response): Promise<void
// Await response from piston execution
try {
const res = await axios.post(
'https://piston.tabot.sh/api/v2/execute',
//https://piston.tabot.sh/api/v2/execute
'',
{
language: item.language,
language: item.language as string,
version: '*',
files: [file],
version: item.language === 'python' ? '3.9.4' : '15.0.2',
stdin: test.in
},
{
Expand All @@ -237,8 +238,9 @@ export const postSubmissions = async (req: Request, res: Response): Promise<void
}
}
)
//This is where we are getting our rejection error
test['stdout'] = res.data.run.code == 0 ? res.data.run.stdout : res.data.run.stderr
if ((res.data.run.output.trim() as string) == (test.out.trim() as string) && res.data.run.code === 0) {
if (((res.data.run.output.trim() as string) == (test.out.trim() as string)) && res.data.run.code === 0) {
console.log('Result: ACCEPTED')
test['result'] = 'accepted'
} else {
Expand All @@ -249,10 +251,10 @@ export const postSubmissions = async (req: Request, res: Response): Promise<void
} catch (e) {
console.log(e)
}
}
}*/
submission.status = status
// Calculate Score
if (status == 'accepted') {
/*if (status == 'accepted') {
let minutes = 0
if (problem.practice) {
minutes = ((submission.date as any) - practice_start_date) / 60
Expand All @@ -265,7 +267,7 @@ export const postSubmissions = async (req: Request, res: Response): Promise<void
} else {
submission.score = 0
}

*/
// Save submission to database
await contest.update_submission(submission.sid as string, { ...submission, sid: submission.sid })
} else if (req.user?.division == 'gold') {
Expand Down
Empty file modified backend/src/api/submissions/putSubmissions.ts
100644 → 100755
Empty file.
98 changes: 83 additions & 15 deletions backend/src/api/submissions/rerunSubmission.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,33 @@ export const rerunSubmission = async (req: Request, res: Response): Promise<void
return
}
const item = matchedData(req)

try {
const submission = await contest.get_submission(item.sid)
const problem = await contest.get_problem(submission.pid)


const { start_date, practice_start_date, points_per_yes, points_per_minute, points_per_no } =
await contest.get_settings()
if (submission) {
let newSubmission = { ...submission }
newSubmission.tests = problem.tests;
submission.tests = problem.tests;
// Update status to 'pending'
// await updateItem('', { submission.sid }, { status: 'pending' });
// Extract details and set defaults
let status = 'accepted'
for (let test of problem.tests) {
// Copy tests from problem
newSubmission.tests = problem.tests
submission.tests = problem.tests
// Run tests
const file = { name: newSubmission.filename as string, content: newSubmission['source'] as string }
const file = { name: submission.filename as string, content: submission['source'] as string }
// Await response from piston execution
try {
/*try {
const res = await axios.post(
'https://piston.tabot.sh/api/v2/execute',
{
language: item.language,
language: item.language as string,
version: '*',
files: [file],
version: item.language === 'python' ? '3.9.4' : '15.0.2',
stdin: test.in
},
{
Expand All @@ -91,24 +92,91 @@ export const rerunSubmission = async (req: Request, res: Response): Promise<void
}
}

newSubmission.status = status
submission.status = status
// Calculate Score
if (status == 'accepted') {
let minutes = 0
if (problem.practice) {
minutes = ((newSubmission.date as any) - practice_start_date) / 60
minutes = ((submission.date as any) - practice_start_date) / 60
} else {
minutes = ((newSubmission.date as any) - start_date) / 60
minutes = ((submission.date as any) - start_date) / 60
}
newSubmission.score = Math.floor(
minutes * points_per_minute + points_per_no * (newSubmission.sub_no as any) + points_per_yes
submission.score = Math.floor(
minutes * points_per_minute + points_per_no * (submission.sub_no as any) + points_per_yes
)
} else {
newSubmission.score = 0
submission.score = 0
}
// update submission
await contest.update_submission(newSubmission.sid as string, { ...newSubmission, sid: newSubmission.sid })
res.send(newSubmission)
await contest.update_submission(submission.sid as string, { ...submission, sid: submission.sid })*/
try {
//console.log(item.language);
const res = await axios.post(
'https://piston.tabot.sh/api/v2/execute',
{
//item.language as string
language: submission.language as string,
version: '*',
files: [file],
stdin: test.in
},
{
headers: {
'Content-Type': 'application/json'
}
}
)
//This is where we are getting our rejection error
//console.log(res.data);
test['stdout'] = res.data.run.code == 0 ? res.data.run.stdout : res.data.run.stderr
//console.log('Ours: ' + res.data.run.output.trim());
//console.log('theirs: ' + test.out.trim());
//console.log(res.data);
//&& res.data.run.code === 0
//console.log(res.data);
if (((res.data.run.stdout.trim() as string) == (test.out.trim() as string))) {
console.log('Result: ACCEPTED')
test['result'] = 'accepted'
} else {
console.log('Result: REJECTED')
status = 'rejected'
test['result'] = 'rejected'
}
} catch (e) {
console.log(e)
}
}
submission.status = status
// Calculate Score
//const base_time_score = 180;
if (status == 'accepted') {
let minutes = 0
if (problem.practice) {
minutes = ((submission.date as any) - practice_start_date) / 60
} else {
minutes = ((submission.date as any) - start_date) / 60
}
/*console.log(base_time_score)
console.log(points_per_yes)
console.log(Number(base_time_score) + Number(points_per_yes) - (minutes * points_per_minute + points_per_no * (submission.sub_no as any)));
console.log(Number(base_time_score) + Number(points_per_yes));
console.log((minutes * points_per_minute + points_per_no * (submission.sub_no as any)))
console.log(minutes * points_per_minute)
console.log(points_per_no * (submission.sub_no as any));*/
submission.score = Math.floor(
minutes * points_per_minute + points_per_no * (submission.sub_no as any) + points_per_yes
)
//Number(base_time_score) + Number(points_per_yes) - (minutes * points_per_minute + points_per_no * (submission.sub_no as any))
//console.log(submission);
//minutes * points_per_minute + points_per_no * (submission.sub_no as any) + points_per_yes
} else {
submission.score = 0
}

// Save submission to database
await contest.update_submission(submission.sid as string, { ...submission, sid: submission.sid })
//await contest.update_submission(submission.sid as string, { ...submission, sid: submission.sid })
res.send(submission)
}
} catch (err) {
console.error(err)
Expand Down
Empty file modified backend/src/api/users/deleteUsers.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/users/getUsers.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/users/index.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/users/postUsers.ts
100644 → 100755
Empty file.
Empty file modified backend/src/api/users/putUsers.ts
100644 → 100755
Empty file.
Empty file modified backend/src/server.ts
100644 → 100755
Empty file.
Empty file modified backend/src/services/db/database.ts
100644 → 100755
Empty file.
Empty file modified backend/src/services/db/dynamo.ts
100644 → 100755
Empty file.
Empty file modified backend/src/services/db/index.ts
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion backend/src/services/db/mongo.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default class MongoDB extends Database {
if (data) resolve(data)
})
})
}

}
count(TableName: string, query?: ScanOptions): Promise<number> {
return new Promise((resolve, reject) => {
this.db
Expand Down
Empty file modified backend/src/services/index.ts
100644 → 100755
Empty file.
Empty file modified backend/src/utils/index.ts
100644 → 100755
Empty file.
Empty file modified backend/tsconfig.json
100644 → 100755
Empty file.
Empty file modified backend/yarn.lock
100644 → 100755
Empty file.
37 changes: 0 additions & 37 deletions docker-compose.prod.yaml

This file was deleted.

Loading
Loading