feat: zvýraznění dnů v historii obsahujících objednávky
CI / Generate TypeScript types (push) Successful in 12s
CI / Server unit tests (push) Successful in 20s
CI / Build server (push) Successful in 24s
CI / Build client (push) Successful in 36s
CI / Playwright E2E tests (push) Successful in 1m17s
CI / Build and push Docker image (push) Successful in 40s
CI / Notify (push) Successful in 2s
CI / Generate TypeScript types (push) Successful in 12s
CI / Server unit tests (push) Successful in 20s
CI / Build server (push) Successful in 24s
CI / Build client (push) Successful in 36s
CI / Playwright E2E tests (push) Successful in 1m17s
CI / Build and push Docker image (push) Successful in 40s
CI / Notify (push) Successful in 2s
This commit is contained in:
@@ -29,4 +29,10 @@ export interface StorageInterface {
|
||||
* @param data data pro uložení
|
||||
*/
|
||||
setData<Type>(key: string, data: Type): Promise<void>;
|
||||
|
||||
/**
|
||||
* Vrátí seznam všech klíčů, případně jen těch obsahujících předaný podřetězec.
|
||||
* @param contains volitelný podřetězec, který musí klíč obsahovat (např. '_extra')
|
||||
*/
|
||||
listKeys(contains?: string): Promise<string[]>;
|
||||
}
|
||||
@@ -29,4 +29,9 @@ export default class JsonStorage implements StorageInterface {
|
||||
db.set(key, data);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
listKeys(contains?: string): Promise<string[]> {
|
||||
const keys = Object.keys(db.JSON());
|
||||
return Promise.resolve(contains ? keys.filter(k => k.includes(contains)) : keys);
|
||||
}
|
||||
}
|
||||
@@ -24,4 +24,9 @@ export default class MemoryStorage implements StorageInterface {
|
||||
store.set(key, data);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
listKeys(contains?: string): Promise<string[]> {
|
||||
const keys = Array.from(store.keys());
|
||||
return Promise.resolve(contains ? keys.filter(k => k.includes(contains)) : keys);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,16 @@ export default class RedisStorage implements StorageInterface {
|
||||
await client.json.set(key, '.', data as any);
|
||||
await client.json.get(key);
|
||||
}
|
||||
|
||||
async listKeys(contains?: string): Promise<string[]> {
|
||||
// SCAN je bezpečnější než KEYS na produkci (neblokuje server)
|
||||
const match = contains ? `*${contains}*` : '*';
|
||||
const keys: string[] = [];
|
||||
for await (const key of client.scanIterator({ MATCH: match, COUNT: 100 })) {
|
||||
// node-redis v4 vrací buď string, nebo (novější verze) pole stringů
|
||||
if (Array.isArray(key)) keys.push(...key);
|
||||
else keys.push(key);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user