Commit e7c58cbc authored by Yechang's avatar Yechang
Browse files

fix(feedback): fix failed displaying ce message

parent 3a96f983
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
import { z } from 'zod';

export const messageSchema = z.object({ data: z.string(), omittedLength: z.number() }).or(z.string())

export const contentSchema = z.discriminatedUnion('type', [
    z.object({
        type: z.literal('ansi'),
        value: z.string()
        value: messageSchema
    }),
    z.object({
        type: z.literal('testcases'),
+1 −3
Original line number Diff line number Diff line
@@ -2,15 +2,13 @@ import { db } from '$lib/server/db'
import { fixAndCalculatePenalty } from '$lib/server/db/feedback.js'
import { log } from '$lib/server/log'
import { redis } from '$lib/server/redis'
import type { contentSchema } from '$lib/shared/feedback.js'
import { messageSchema, type contentSchema } from '$lib/shared/feedback'
import { TaskStatus } from '@prisma/client'
import { error, json } from '@sveltejs/kit'
import _ from 'lodash'
import { z } from 'zod'


const messageSchema = z.object({ data: z.string(), omittedLength: z.number() }).or(z.string())

const schema = z.discriminatedUnion('status', [
    z.object({
        compile: z.object({ success: z.literal(false), message: messageSchema }),
+11 −3
Original line number Diff line number Diff line
@@ -84,9 +84,17 @@
			{/if}
			{#each result.data as item}
				{#if item.type === 'ansi'}
					{#if typeof item.value ==='object'}
						<code class="whitespace-pre">
							{@html ansi_up.ansi_to_html(item.value.data)}
						</code>
						<div>({item.value.omittedLength} bytes omitted.)</div>
					{:else}
						
						<code class="whitespace-pre">
							{@html ansi_up.ansi_to_html(item.value)}
						</code>
					{/if}
				{:else if item.type === 'score'}
					<div>Score: {item.value}</div>
				{:else if item.type === 'status'}