Commit a38df6eb authored by Yechang's avatar Yechang
Browse files

feat: file

parent 530aec52
Loading
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
import { db } from '$lib/server/db';
import { json } from '@sveltejs/kit';

export const GET = async ({ params }) => {
    const { id } = params;

    const volume = await db.file.findMany({
        where: {
            volume: id
        }
    })

    return json({ volume })
} 
 No newline at end of file
+17 −0
Original line number Diff line number Diff line
import { db } from '$lib/server/db';
import { signDownloadRequest } from '$lib/server/storage';
import { json } from '@sveltejs/kit';

export const GET = async ({ params }) => {
    const { id } = params;

    const file = await db.file.findUnique({
        where: {
            id
        }
    })

    const url = await signDownloadRequest(file.id)

    return json({ ...file, url })
} 
 No newline at end of file
+9 −10
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ import { log } from '$lib/server/log'
import { redis } from '$lib/server/redis'
import { messageSchema, type contentSchema } from '$lib/shared/feedback'
import { TaskStatus } from '@prisma/client'
import { error, json } from '@sveltejs/kit'
import { error } from '@sveltejs/kit'
import _ from 'lodash'
import { z } from 'zod'

@@ -110,7 +110,7 @@ export const PUT = async ({ request, params }) => {
        const res = parsed.data

        if (res.status === 'CompilationError') {
            const feedback = await db.submissionFeedback.upsert({
            await db.submissionFeedback.upsert({
                where: {
                    submissionId: task.submissionId,
                },
@@ -177,6 +177,11 @@ export const PUT = async ({ request, params }) => {
            return new Response(null, { status: 201 })
        }

        const testcases = _.entries(res.testcaseResult).map(([key, v]) => {
            const { input, output, userOutput, userError, ...data } = v
            return data
        })

        await db.submissionFeedback.upsert({
            where: {
                submissionId: task.submissionId,
@@ -195,10 +200,7 @@ export const PUT = async ({ request, params }) => {
                    },
                    {
                        type: "testcases",
                        value: _.entries(res.testcaseResult).map(([key, v]) => {
                            const { input, output, userOutput, userError, ...data } = v
                            return data
                        })
                        value: testcases
                    }
                ] as z.infer<typeof contentSchema>,
                submissionId: task.submissionId,
@@ -219,10 +221,7 @@ export const PUT = async ({ request, params }) => {
                    },
                    {
                        type: "testcases",
                        value: _.entries(res.testcaseResult).map(([key, v]) => {
                            const { input, output, userOutput, userError, ...data } = v
                            return data
                        })
                        value: testcases
                    }
                ] as z.infer<typeof contentSchema>,
                submissionId: task.submissionId,
+1 −1
Original line number Diff line number Diff line
@@ -122,6 +122,6 @@ export const load = (async ({ parent, params }) => {

export const actions = {
    default: async (event) => {
        // TODO log the user in
        
    }
} satisfies Actions; 
 No newline at end of file
+11 −1
Original line number Diff line number Diff line
<script lang="ts">
	import Button from '$lib/components/ui/button/button.svelte';
	import type { PageData } from './$types';
	export let data: PageData;

@@ -12,8 +13,17 @@
	<div class="space-y-4 py-6">
		<div class="flex h-full justify-center">
			{#each submissions as submission (submission.id)}
				{submission.id} {submission.submitter.sustechId} {submission.feedback?.score}
				<div>
					{submission.id}
					{submission.submitter.sustechId}
					{submission.feedback?.score}
				</div>
			{/each}
		</div>
		<div>
			<form method="POST">
				<Button type="submit">Similarity Check</Button>
			</form>
		</div>
	</div>
</div>