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 { 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; });