/* Espe | Ein schlichtes Werkzeug zur Mitglieder-Verwaltung | Frontend Copyright (C) 2024 Christian Fraß This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ namespace _espe.logic { /** */ let _cache : lib_plankton.cache.type_subject; /** */ export async function init( ) : Promise { _cache = lib_plankton.cache.make( { // "chest": lib_plankton.storage.memory.implementation_chest({}), } ); await lib_plankton.cache.init( _cache ); } /** */ export function group_data( ) : Promise< { pool : Map< int, { name : string; label : string; } >; order : Array; } > { return lib_plankton.cache.get< { pool : Map< int, { name : string; label : string; } >; order : Array; } >( _cache, "group_data", 120, async () => { const array : Array< { id : int; preview : { name : string; label : string; }; } > = await _espe.backend.group_list(); const pool : Map = new Map(); const order : Array = new Array(); for (const entry of array) { pool.set( entry.id, { "name": entry.preview.name, "label": entry.preview.label, } ); order.push(entry.id); } return { "pool": pool, "order": order, }; } ); } }