|
|
|
@ -10,36 +10,36 @@ |
|
|
|
|
--> |
|
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
|
|
import { onMount, tick, onDestroy } from "svelte"; |
|
|
|
|
import { |
|
|
|
|
sparql_update, |
|
|
|
|
sparql_query, |
|
|
|
|
toast_error, |
|
|
|
|
toast_success, |
|
|
|
|
active_session, |
|
|
|
|
display_error, |
|
|
|
|
online |
|
|
|
|
} from "../store"; |
|
|
|
|
import ng from "../api"; |
|
|
|
|
import { |
|
|
|
|
in_memory_discrete, open_viewer, set_viewer, set_editor, set_view_or_edit, cur_tab_doc_can_edit, cur_tab |
|
|
|
|
} from "../tab"; |
|
|
|
|
import{ PencilSquare, Lifebuoy } from "svelte-heros-v2"; |
|
|
|
|
import { t } from "svelte-i18n"; |
|
|
|
|
import { Button, Progressbar, Spinner, Alert } from "flowbite-svelte"; |
|
|
|
|
|
|
|
|
|
import Highlight, { LineNumbers } from "svelte-highlight"; |
|
|
|
|
import hljs from "highlight.js"; |
|
|
|
|
import { definer } from "../turtle"; |
|
|
|
|
import "svelte-highlight/styles/github.css"; |
|
|
|
|
const language = { |
|
|
|
|
name: "turtle", |
|
|
|
|
register: (hljs) => { |
|
|
|
|
return definer(hljs); |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
import { onMount, tick, onDestroy } from "svelte"; |
|
|
|
|
import { |
|
|
|
|
sparql_update, |
|
|
|
|
sparql_query, |
|
|
|
|
toast_error, |
|
|
|
|
toast_success, |
|
|
|
|
active_session, |
|
|
|
|
display_error, |
|
|
|
|
online |
|
|
|
|
} from "../store"; |
|
|
|
|
import ng from "../api"; |
|
|
|
|
import { |
|
|
|
|
in_memory_discrete, open_viewer, set_viewer, set_editor, set_view_or_edit, cur_tab_doc_can_edit, cur_tab |
|
|
|
|
} from "../tab"; |
|
|
|
|
import{ PencilSquare, Lifebuoy } from "svelte-heros-v2"; |
|
|
|
|
import { t } from "svelte-i18n"; |
|
|
|
|
import { Button, Progressbar, Spinner, Alert } from "flowbite-svelte"; |
|
|
|
|
|
|
|
|
|
import Highlight, { LineNumbers } from "svelte-highlight"; |
|
|
|
|
import hljs from "highlight.js"; |
|
|
|
|
import { definer } from "../turtle"; |
|
|
|
|
import "svelte-highlight/styles/github.css"; |
|
|
|
|
const language = { |
|
|
|
|
name: "turtle", |
|
|
|
|
register: (hljs) => { |
|
|
|
|
return definer(hljs); |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const ranking_query = `SELECT ?mail (SAMPLE(?n) as?name) (MAX(?rust_) as ?rust) (MAX(?svelte_) as ?svelte) (MAX(?tailwind_) as ?tailwind) |
|
|
|
|
const ranking_query = `SELECT ?mail (SAMPLE(?n) as?name) (MAX(?rust_) as ?rust) (MAX(?svelte_) as ?svelte) (MAX(?tailwind_) as ?tailwind) |
|
|
|
|
(MAX(?rdf_) as ?rdf) (MAX(?yjs_) as ?yjs) (MAX(?automerge_) as ?automerge) (SUM(?total_) as ?total) |
|
|
|
|
WHERE { |
|
|
|
|
{ SELECT ?mail (SAMPLE(?name) as ?n) ?skill (AVG(?value)+1 AS ?score) |
|
|
|
@ -61,20 +61,20 @@ WHERE { |
|
|
|
|
} GROUP BY ?mail |
|
|
|
|
ORDER BY DESC(?total)`; |
|
|
|
|
|
|
|
|
|
export let commits = {graph:[]}; |
|
|
|
|
let source = ""; |
|
|
|
|
$: source = commits.graph.join(" .\r\n") + (commits.graph.length ? " .":""); |
|
|
|
|
export let commits = {graph:[]}; |
|
|
|
|
let source = ""; |
|
|
|
|
$: source = commits.graph.join(" .\r\n") + (commits.graph.length ? " .":""); |
|
|
|
|
|
|
|
|
|
let results = []; |
|
|
|
|
let results = []; |
|
|
|
|
|
|
|
|
|
$: if (commits.graph.length > 4) { |
|
|
|
|
sparql_query(ranking_query, false).then((res) => { |
|
|
|
|
//console.log(res.results?.bindings); |
|
|
|
|
results = res.results?.bindings; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
$: if (commits.graph.length > 4) { |
|
|
|
|
sparql_query(ranking_query, false).then((res) => { |
|
|
|
|
//console.log(res.results?.bindings); |
|
|
|
|
results = res.results?.bindings; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const query = `PREFIX vcard: <http://www.w3.org/2006/vcard/ns#> |
|
|
|
|
const query = `PREFIX vcard: <http://www.w3.org/2006/vcard/ns#> |
|
|
|
|
PREFIX xskills: <did:ng:x:skills#> |
|
|
|
|
PREFIX ksp: <did:ng:k:skills:programming:> |
|
|
|
|
PREFIX ng: <did:ng:x:ng#> |
|
|
|
@ -109,87 +109,87 @@ WHERE { |
|
|
|
|
) ) |
|
|
|
|
}`; |
|
|
|
|
|
|
|
|
|
const openQuery = async () => { |
|
|
|
|
|
|
|
|
|
//TODO : return now if already processing (when LDO for svelte is ready) |
|
|
|
|
// and even disable the button in that case |
|
|
|
|
try { |
|
|
|
|
await sparql_update(`INSERT DATA { <> <did:ng:x:ng#social_query_sparql> \"${query.replaceAll("\n"," ")}\".}`); |
|
|
|
|
let commit_id = commits.heads[0]; |
|
|
|
|
let commit_key = commits.head_keys[0]; |
|
|
|
|
let session = $active_session; |
|
|
|
|
if (!session) return; |
|
|
|
|
let request_nuri = "did:ng:"+$cur_tab.doc.nuri+":c:"+commit_id+":k:"+commit_key; |
|
|
|
|
await ng.social_query_start( |
|
|
|
|
session.session_id, |
|
|
|
|
"did:ng:a", |
|
|
|
|
request_nuri, |
|
|
|
|
"did:ng:d:c", |
|
|
|
|
0, |
|
|
|
|
); |
|
|
|
|
} catch (e) { |
|
|
|
|
toast_error(display_error(e)); |
|
|
|
|
} |
|
|
|
|
const openQuery = async () => { |
|
|
|
|
|
|
|
|
|
//TODO : return now if already processing (when LDO for svelte is ready) |
|
|
|
|
// and even disable the button in that case |
|
|
|
|
try { |
|
|
|
|
await sparql_update(`INSERT DATA { <> <did:ng:x:ng#social_query_sparql> \"${query.replaceAll("\n"," ")}\".}`); |
|
|
|
|
let commit_id = commits.heads[0]; |
|
|
|
|
let commit_key = commits.head_keys[0]; |
|
|
|
|
let session = $active_session; |
|
|
|
|
if (!session) return; |
|
|
|
|
let request_nuri = "did:ng:"+$cur_tab.doc.nuri+":c:"+commit_id+":k:"+commit_key; |
|
|
|
|
await ng.social_query_start( |
|
|
|
|
session.session_id, |
|
|
|
|
"did:ng:a", |
|
|
|
|
request_nuri, |
|
|
|
|
"did:ng:d:c", |
|
|
|
|
0, |
|
|
|
|
); |
|
|
|
|
} catch (e) { |
|
|
|
|
toast_error(display_error(e)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onMount(()=>{ |
|
|
|
|
//console.log($active_session); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|
<div class="flex-col"> |
|
|
|
|
<p class="p-3"> |
|
|
|
|
Social Query |
|
|
|
|
</p> |
|
|
|
|
<Button |
|
|
|
|
on:click={openQuery} |
|
|
|
|
on:keypress={openQuery} |
|
|
|
|
disabled={!$online} |
|
|
|
|
class="select-none ml-2 mt-2 mb-2 text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:ring-primary-500/50 rounded-lg text-base p-2 text-center inline-flex items-center dark:focus:ring-primary-700/55" |
|
|
|
|
> |
|
|
|
|
<Lifebuoy tabindex="-1" class="mr-2 focus:outline-none" /> |
|
|
|
|
Start query |
|
|
|
|
</Button> |
|
|
|
|
onMount(()=>{ |
|
|
|
|
//console.log($active_session); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
<div class="relative overflow-x-auto"> |
|
|
|
|
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 table-auto"> |
|
|
|
|
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400"> |
|
|
|
|
<th scope="col" class="px-6 py-3">Email</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Name</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Rust</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Svelte</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Tailwind</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Rdf</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Yjs</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Automerge</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Total</th> |
|
|
|
|
</thead> |
|
|
|
|
<tbody> |
|
|
|
|
{#each results as res} |
|
|
|
|
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700 border-gray-200"> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{res.mail.value}</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{res.name.value}</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.rust.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.svelte.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.tailwind.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.rdf.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.yjs.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.automerge.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.total.value * 10) / 10 }</td> |
|
|
|
|
</tr> |
|
|
|
|
{/each} |
|
|
|
|
</tbody> |
|
|
|
|
</table> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<p class="p-3 mt-10"> |
|
|
|
|
Raw data |
|
|
|
|
</p> |
|
|
|
|
{#if source} |
|
|
|
|
<Highlight {language} code={source} class="mb-10" let:highlighted > |
|
|
|
|
<LineNumbers {highlighted} wrapLines hideBorder /> |
|
|
|
|
</Highlight> |
|
|
|
|
{/if} |
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<div class="flex-col"> |
|
|
|
|
<p class="p-3"> |
|
|
|
|
Social Query |
|
|
|
|
</p> |
|
|
|
|
<Button |
|
|
|
|
on:click={openQuery} |
|
|
|
|
on:keypress={openQuery} |
|
|
|
|
disabled={!$online} |
|
|
|
|
class="select-none ml-2 mt-2 mb-2 text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:ring-primary-500/50 rounded-lg text-base p-2 text-center inline-flex items-center dark:focus:ring-primary-700/55" |
|
|
|
|
> |
|
|
|
|
<Lifebuoy tabindex="-1" class="mr-2 focus:outline-none" /> |
|
|
|
|
Start query |
|
|
|
|
</Button> |
|
|
|
|
|
|
|
|
|
<div class="relative overflow-x-auto"> |
|
|
|
|
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 table-auto"> |
|
|
|
|
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400"> |
|
|
|
|
<th scope="col" class="px-6 py-3">Email</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Name</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Rust</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Svelte</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Tailwind</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Rdf</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Yjs</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Automerge</th> |
|
|
|
|
<th scope="col" class="px-6 py-3">Total</th> |
|
|
|
|
</thead> |
|
|
|
|
<tbody> |
|
|
|
|
{#each results as res} |
|
|
|
|
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700 border-gray-200"> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{res.mail.value}</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{res.name.value}</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.rust.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.svelte.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.tailwind.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.rdf.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.yjs.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.automerge.value * 10) / 10 }</td> |
|
|
|
|
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">{Math.round(res.total.value * 10) / 10 }</td> |
|
|
|
|
</tr> |
|
|
|
|
{/each} |
|
|
|
|
</tbody> |
|
|
|
|
</table> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<p class="p-3 mt-10"> |
|
|
|
|
Raw data |
|
|
|
|
</p> |
|
|
|
|
{#if source} |
|
|
|
|
<Highlight {language} code={source} class="mb-10" let:highlighted > |
|
|
|
|
<LineNumbers {highlighted} wrapLines hideBorder /> |
|
|
|
|
</Highlight> |
|
|
|
|
{/if} |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|