Skip to content
Open
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
7 changes: 2 additions & 5 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ PORT_WEB=80
PORT_SERVER=3000
PORT_CENTRAL_SERVICE=5050
PORT_RTC_SERVICE=5001
PORT_KAFKA=29092
PORT_ADMINER=8080
PORT_REDIS_INSIGHT=8001
POSTGRES_USER=
Expand All @@ -15,11 +14,9 @@ LEETCODE_USERNAME=
LEETCODE_PASSWORD=
MAX_NUM_ROUND_PER_ROOM=
REDIS_PASSWORD=
KAFKA_BROKER=
WORKER_ID=
KAFKA_EGRESS_TOPIC=
KAFKA_INGRESS_TOPIC=
KAFKA_CENTRAL_SERVICE_GID=
REDIS_SUBMISSION_QUEUE=submission-ingress
REDIS_EGRESS_QUEUE=submission-egress
SERVER_SECRET=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
Expand Down
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: test test-go test-node test-server test-frontend test-central test-rtc test-worker test-kafka help
.PHONY: test test-go test-node test-server test-frontend test-central test-rtc test-worker help

help:
@echo "Available test commands:"
Expand All @@ -10,7 +10,6 @@ help:
@echo " make test-central - Run central-service tests only"
@echo " make test-rtc - Run rtc-service tests only"
@echo " make test-worker - Run worker-service tests only"
@echo " make test-kafka - Run kafka-queue tests only"

# Run all tests
test: test-go test-node
Expand All @@ -22,7 +21,6 @@ test-go:
@cd central-service && go test ./... -v
@cd rtc-service && go test ./... -v
@cd worker-service && go test ./... -v
@cd kafka-queue && go test ./... -v
@echo "✓ Go tests completed"

# Run all Node.js tests
Expand Down Expand Up @@ -55,7 +53,3 @@ test-rtc:
test-worker:
@echo "Running worker-service tests..."
@cd worker-service && go test ./... -v

test-kafka:
@echo "Running kafka-queue tests..."
@cd kafka-queue && go test ./... -v
6 changes: 3 additions & 3 deletions bsg-frontend/apps/extension/hooks/useRoundTimer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { useRoomStore } from "@/stores/useRoomStore";
export function useRoundTimer() {

const roundEndTime = useRoomStore(s => s.roundEndTime);
const [ timeRemaining, setTimeRemaining ] = useState<string>("00:00:00");
const [ timeRemaining, setTimeRemaining ] = useState<string>("00:00");

useEffect(() => {
if (!roundEndTime) {
setTimeRemaining("00:00:00");
setTimeRemaining("00:00");
return;
}

Expand All @@ -17,7 +17,7 @@ export function useRoundTimer() {
const diff = roundEndTime - now;

if (diff <= 0) {
setTimeRemaining("00:00:00");
setTimeRemaining("00:00");
// onEndRound(); // timer expired — end the round
} else {
const hours = Math.floor(diff / 3600000);
Expand Down
31 changes: 2 additions & 29 deletions central-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
FROM golang:1.25-bookworm

# Install build dependencies for librdkafka
RUN apt-get update && apt-get install -y \
build-essential \
libssl-dev \
libsasl2-dev \
libzstd-dev \
pkg-config \
git \
&& rm -rf /var/lib/apt/lists/*

# Build librdkafka from source for ARM64 compatibility
RUN git clone https://github.com/confluentinc/librdkafka.git && \
cd librdkafka && \
git checkout v2.0.2 && \
./configure && \
make && \
make install && \
cd .. && \
rm -rf librdkafka

# Update library path
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

WORKDIR /app

# listen, the build was failing and i couldn't figure out why so
# this is what ai got me, i don't know if it's optimal but it works
COPY go.work go.work.sum ./
COPY central-service/go.mod central-service/go.sum ./central-service/
COPY rtc-service/go.mod rtc-service/go.sum ./rtc-service/
COPY kafka-queue/go.mod kafka-queue/go.sum ./kafka-queue/
COPY worker-service/go.mod worker-service/go.sum ./worker-service/

# Download dependencies for central-service
Expand All @@ -41,11 +15,10 @@ RUN go mod download
WORKDIR /app
COPY central-service ./central-service
COPY rtc-service ./rtc-service
COPY kafka-queue ./kafka-queue
COPY worker-service ./worker-service

# Build with dynamic linking
# Build
WORKDIR /app/central-service
RUN CGO_ENABLED=1 GOOS=linux go build -tags dynamic -o ./central-service
RUN CGO_ENABLED=0 GOOS=linux go build -o ./central-service

CMD ["/app/central-service/central-service"]
31 changes: 31 additions & 0 deletions central-service/dto/dto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dto

import "github.com/acmutd/bsg/central-service/models"

type SubmissionIngressDTO struct {
ProblemSlug string `json:"problemSlug"`
ProblemId uint `json:"problemID"`
Lang string `json:"lang"`
Code string `json:"code"`
Verdict string `json:"verdict"`
SubmissionId uint `json:"submissionID"`
}

type SubmissionEgressDTO struct {
SubmissionId uint `json:"submissionID"`
Verdict string `json:"verdict"`

// this will store info such as which test case got wrong answer verdict, expected answer, etc..
Data []byte `json:"data"`
}

func NewSubmissionIngressDTO(problem *models.Problem, submission *models.RoundSubmission) SubmissionIngressDTO {
return SubmissionIngressDTO{
ProblemSlug: problem.Slug,
ProblemId: problem.ID,
Lang: submission.Submission.Language,
Code: submission.Submission.Code,
Verdict: submission.Submission.Verdict,
SubmissionId: submission.ID,
}
}
7 changes: 5 additions & 2 deletions central-service/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
firebase.google.com/go v3.13.0+incompatible
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/acmutd/bsg/rtc-service v0.0.0-20240402145408-434f26651f08
github.com/confluentinc/confluent-kafka-go v1.9.2
github.com/google/uuid v1.3.1
github.com/alicebob/miniredis/v2 v2.38.0
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.1
github.com/labstack/echo/v4 v4.11.1
github.com/madflojo/tasks v1.1.0
Expand Down Expand Up @@ -46,15 +46,18 @@ require (
github.com/jackc/pgx/v5 v5.4.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/yuin/gopher-lua v1.1.1 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.48.0 // indirect
golang.org/x/net v0.50.0 // indirect
Expand Down
Loading
Loading