aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/game/hub.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-09-05 21:12:03 +0900
committernsfisis <nsfisis@gmail.com>2025-09-05 21:12:03 +0900
commit2fb0b6516b9731ca832a31f6b31515f4eb056cb1 (patch)
treee2f4f82d783799f84a111179075e3da11cdb9e80 /backend/game/hub.go
parent82d3cf35c3c6b85b48c94dd6301c8bf718669b8d (diff)
downloadiosdc-japan-2025-albatross-2fb0b6516b9731ca832a31f6b31515f4eb056cb1.tar.gz
iosdc-japan-2025-albatross-2fb0b6516b9731ca832a31f6b31515f4eb056cb1.tar.zst
iosdc-japan-2025-albatross-2fb0b6516b9731ca832a31f6b31515f4eb056cb1.zip
feat(backend): support swift language
Diffstat (limited to 'backend/game/hub.go')
-rw-r--r--backend/game/hub.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/backend/game/hub.go b/backend/game/hub.go
index 3697b4a..8f27466 100644
--- a/backend/game/hub.go
+++ b/backend/game/hub.go
@@ -36,12 +36,17 @@ func (hub *Hub) Run() {
go hub.processTaskResults()
}
-func (hub *Hub) CalcCodeSize(code string) int {
+func (hub *Hub) CalcCodeSize(code string, language string) int {
re := regexp.MustCompile(`\s+`)
- return len(strings.TrimSuffix(strings.TrimPrefix(strings.TrimPrefix(re.ReplaceAllString(code, ""), "<?php"), "<?"), "?>"))
+ trimmed := re.ReplaceAllString(code, "")
+ if language == "php" {
+ return len(strings.TrimSuffix(strings.TrimPrefix(strings.TrimPrefix(trimmed, "<?php"), "<?"), "?>"))
+ } else {
+ return len(trimmed)
+ }
}
-func (hub *Hub) EnqueueTestTasks(ctx context.Context, submissionID, gameID, userID int, code string) error {
+func (hub *Hub) EnqueueTestTasks(ctx context.Context, submissionID, gameID, userID int, language, code string) error {
rows, err := hub.q.ListTestcasesByGameID(ctx, int32(gameID))
if err != nil {
return err
@@ -52,6 +57,7 @@ func (hub *Hub) EnqueueTestTasks(ctx context.Context, submissionID, gameID, user
userID,
submissionID,
int(row.TestcaseID),
+ language,
code,
row.Stdin,
row.Stdout,