ui: Use $lib instead of ../../../../ mess
This commit is contained in:
parent
3cf92b4798
commit
3a6daa3d04
48 changed files with 81 additions and 81 deletions
|
|
@ -1,69 +0,0 @@
|
|||
import { derived } from 'svelte/store';
|
||||
|
||||
import seedrandom from 'seedrandom';
|
||||
|
||||
import { my } from './my.js';
|
||||
import { themesStore } from './themes.js';
|
||||
|
||||
export const myThemes = derived([my, themesStore], ([$my, $themesStore]) => {
|
||||
const themes = {};
|
||||
|
||||
for (let key in $themesStore.themes) {
|
||||
themes[key] = {exercice_solved: 0};
|
||||
|
||||
if ($my && $my.exercices) {
|
||||
for (let k in $themesStore.themes[key].exercices) {
|
||||
if ($my.exercices[k] && $my.exercices[k].solved_rank) {
|
||||
themes[key].exercice_solved++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return themes;
|
||||
});
|
||||
|
||||
export const themes = derived(
|
||||
[my, themesStore],
|
||||
([$my, $themesStore]) => {
|
||||
const arr = [];
|
||||
for (let th in $themesStore.themes) {
|
||||
$themesStore.themes[th].id = th
|
||||
arr.push($themesStore.themes[th]);
|
||||
}
|
||||
const size = arr.length;
|
||||
const rng = new seedrandom($my && $my.team_id ? $my.team_id : 0);
|
||||
const resp = [];
|
||||
const keys = [];
|
||||
|
||||
for(let i=0;i<size;i++) keys.push(i);
|
||||
for(let i=0;i<size;i++) {
|
||||
const r = Math.floor(rng() * keys.length);
|
||||
const g = keys[r];
|
||||
keys.splice(r,1);
|
||||
resp.push(arr[g]);
|
||||
}
|
||||
|
||||
return resp;
|
||||
},
|
||||
);
|
||||
|
||||
export const tags = derived([my, themesStore], ([$my, $themesStore]) => {
|
||||
const tags = {};
|
||||
|
||||
for (let key in $themesStore.themes) {
|
||||
for (let k in $themesStore.themes[key].exercices) {
|
||||
$themesStore.themes[key].exercices[k].tags.forEach((tag) => {
|
||||
if (!tags[tag])
|
||||
tags[tag] = {count: 1, solved: 0};
|
||||
else
|
||||
tags[tag].count += 1;
|
||||
|
||||
if ($my && $my.exercices && $my.exercices[k] && $my.exercices[k].solved_rank)
|
||||
tags[tag].solved += 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return tags;
|
||||
});
|
||||
Reference in a new issue