Skip to content
Merged
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
42 changes: 32 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
node_modules
# Keep environment variables out of version control
# Dependencies
node_modules/
**/node_modules/
.pnpm-store/

# Environment and secrets
.env
.env.*
!.env.example
!.env.*.example

# Logs and runtime files
logs/
**/logs/
*.log
*.pid
*.seed
*.pid.lock
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Build/test output
dist/
build/
coverage/
*.tsbuildinfo

# OS / editor local files
.DS_Store
workers/node_modules
backend/node_modules
frontend/node_modules
.DS_Store
.env
.pnpm-store
.DS_Store
.codex
.codex
.vscode/
.idea/
6 changes: 5 additions & 1 deletion Frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ dist
dist-ssr
*.local
.env
.env.*
!.env.example
!.env.*.example
coverage/

# Editor directories and files
.vscode/*
Expand All @@ -24,4 +28,4 @@ dist-ssr
*.sln
*.sw?

.DS_Store
.DS_Store
12 changes: 11 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,14 @@ dist
# SvelteKit build / generate output
.svelte-kit

# End of https://www.toptal.com/developers/gitignore/api/node
# End of https://www.toptal.com/developers/gitignore/api/node

# CodeSM backend local-only files
.env
.env.*
!.env.example
logs/
scratch/
dist/
node_modules/
*.log

This file was deleted.

122 changes: 0 additions & 122 deletions backend/logs/combined/combined-2026-04-20.log

This file was deleted.

1,861 changes: 0 additions & 1,861 deletions backend/logs/combined/combined-2026-04-21.log

This file was deleted.

8 changes: 0 additions & 8 deletions backend/logs/error/error-2026-03-31.log

This file was deleted.

1 change: 0 additions & 1 deletion backend/logs/error/error-2026-04-20.log

This file was deleted.

5 changes: 0 additions & 5 deletions backend/logs/error/error-2026-04-21.log

This file was deleted.

5 changes: 4 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"lint": "eslint --ext .js,.ts src",
"lint:fix": "eslint --fix --ext .js,.ts src",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
"db:sync": "pnpm add file:../db-schema && drizzle-kit generate && drizzle-kit migrate"
"db:sync": "pnpm add file:../db-schema && drizzle-kit generate && drizzle-kit migrate",
"migrate:mongo:users": "node src/scripts/migrate-mongo-users-to-postgres.js",
"migrate:mongo:problems": "node src/scripts/migrate-mongo-problems-to-postgres.js",
"migrate:mongo:submissions": "node src/scripts/migrate-mongo-submissions-to-postgres.js"
},
"keywords": [],
"author": "",
Expand Down
47 changes: 31 additions & 16 deletions backend/src/api/submission/submission-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,7 @@ export const handlegetSubmissionStatus = async (
submissionId: string
): Promise<IGetSubmissionResponse> => {
try {

const redisStatus = await redis.get(`submission:${submissionId}`);
if (redisStatus) {
const parsed = JSON.parse(redisStatus);
return {
submissionId,
status: parsed.status,
startedAt : new Date(parsed.createdAt),
};
}

const [result] = await db
const [dbResult] = await db
.select({
id: submission.id,
status: submission.status,
Expand All @@ -104,14 +93,40 @@ export const handlegetSubmissionStatus = async (
.from(submission)
.where(eq(submission.id, submissionId));

if (!result) {
if (!dbResult) {
throw new ApiError('Submission not found', httpStatus.NOT_FOUND);
}

const redisStatus = await redis.get(`submission:${submissionId}`);
if (redisStatus) {
const parsed = JSON.parse(redisStatus);

const redisState = String(parsed?.status || '').toUpperCase();
const dbState = String(dbResult.status || '').toUpperCase();
const dbIsTerminal = dbState === 'COMPLETED' || dbState === 'FAILED';
const redisIsNonTerminal = redisState === 'PENDING' || redisState === 'RUNNING';

// If Redis is stale (still running/pending) but DB is already terminal,
// trust DB to avoid frontend getting stuck in "Running".
if (dbIsTerminal && redisIsNonTerminal) {
return {
submissionId: dbResult.id,
status: dbResult.status,
startedAt: new Date(dbResult.createdAt),
};
}

return {
submissionId,
status: parsed.status,
startedAt: new Date(parsed.updatedAt || parsed.createdAt || dbResult.createdAt),
};
}

return {
submissionId: result.id,
status: result.status,
startedAt : new Date(result.createdAt),
submissionId: dbResult.id,
status: dbResult.status,
startedAt : new Date(dbResult.createdAt),
};
} catch (error) {
console.error("Database error:", error);
Expand Down
2 changes: 1 addition & 1 deletion backend/src/loaders/postgres.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Pool } from 'pg';
import { drizzle } from 'drizzle-orm/node-postgres';
import logger from './logger';
import { schema } from 'db-schema';
import { schema } from '../../../db-schema/src/index';
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing the schema via a deep relative path (../../../db-schema/src/index) tightly couples backend to the monorepo folder layout and bypasses the existing TS path mapping for db-schema (see backend/tsconfig.json paths). Prefer importing from db-schema and fixing the package to export/build the intended entrypoint (e.g., ensure ../db-schema/dist exists or adjust db-schema exports/paths).

Suggested change
import { schema } from '../../../db-schema/src/index';
import { schema } from 'db-schema';

Copilot uses AI. Check for mistakes.

function createDrizzle(pool: Pool) {
return drizzle(pool, { schema });
Expand Down
Loading
Loading