Skip to content
Snippets Groups Projects
Commit 77b6a6df authored by Linus Keiser's avatar Linus Keiser :speech_balloon:
Browse files

--wip--

parent d6169aec
No related branches found
No related tags found
No related merge requests found
Pipeline #590810 passed
<script lang="ts"> <script lang="ts">
import type { AnnotationEditorProps, SourceSelection } from './types'; import type { AnnotationEditorProps, SourceSelection } from './types';
import CodeBlock from './CodeBlock.svelte'; import CodeBlock from './CodeBlock.svelte';
import { onDestroy, onMount } from 'svelte';
import { liveEvaluation } from './live.svelte';
let { submission, evaluation, onSave = (_) => {} }: AnnotationEditorProps = $props(); let { submission, evaluation, onSave = (_) => {} }: AnnotationEditorProps = $props();
...@@ -10,6 +12,9 @@ ...@@ -10,6 +12,9 @@
let scoreDelta = $state(0); let scoreDelta = $state(0);
let annotationColor = $state('#ffeb3b'); // Default yellow let annotationColor = $state('#ffeb3b'); // Default yellow
let liveQueryId: string | null = $state(null);
$inspect(liveQueryId);
const handleSelectionChange = (srcSelection: SourceSelection) => { const handleSelectionChange = (srcSelection: SourceSelection) => {
sourceSelection = srcSelection; sourceSelection = srcSelection;
}; };
...@@ -46,6 +51,12 @@ ...@@ -46,6 +51,12 @@
scoreDelta = 0; scoreDelta = 0;
}; };
onMount(async () => {
if (!evaluation) return;
liveQueryId = (await liveEvaluation(evaluation.id.toString())).toString();
});
onDestroy(() => {});
/* /*
// helper to determine if the selection is a point, in which case we want to annotate the whole line it's on // helper to determine if the selection is a point, in which case we want to annotate the whole line it's on
function isSelectionPoint(s: SourceSelection): boolean { function isSelectionPoint(s: SourceSelection): boolean {
......
import { getDb } from '$lib/surreal.svelte'; import { getDb } from '$lib/surreal.svelte';
const liveEvaluation = async (evalId: string) => { export const liveEvaluation = async (evalId: string) => {
// const db = await getDb(); const db = await getDb();
// await db.signin({username: "root", password: "root"}); await db.signin({ username: 'root', password: 'root' });
// db.live()
const queryId = await db.live(
'evaluation',
(action, result) => {
if (action === 'CLOSE') console.log('Closing live connection');
if (action === 'UPDATE') console.log(result);
},
false
);
return queryId;
}; };
...@@ -17,7 +17,7 @@ type DbConfig = { ...@@ -17,7 +17,7 @@ type DbConfig = {
}; };
const DEFAULT_CONFIG: DbConfig = { const DEFAULT_CONFIG: DbConfig = {
url: 'http://localhost:8000', url: 'ws://localhost:8000/rpc',
namespace: 'grady', namespace: 'grady',
database: 'dev' database: 'dev'
}; };
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import { annotateSubmission } from '$lib/db/queries'; import { annotateSubmission } from '$lib/db/queries';
import { RecordId, StringRecordId } from 'surrealdb'; import { RecordId, StringRecordId } from 'surrealdb';
import type { PageProps } from './$types'; import type { PageProps } from './$types';
import { onDestroy, onMount } from 'svelte';
('$lib/components/AnnotationEditor'); ('$lib/components/AnnotationEditor');
// TODO live query // TODO live query
...@@ -14,7 +15,7 @@ ...@@ -14,7 +15,7 @@
const hasOngoingEvaluation = $derived(data.evaluation !== null); const hasOngoingEvaluation = $derived(data.evaluation !== null);
const onSave = async (annotation: Annotation) => { const onSave = async (annotation: Annotation) => {
await annotateSubmission(new StringRecordId(data.evaluation.id), annotation); //await annotateSubmission(new StringRecordId(data.evaluation.id), annotation);
}; };
function formatJson(obj: any) { function formatJson(obj: any) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment