feat: process worker messages in queue

This commit is contained in:
2024-01-18 11:17:57 +00:00
parent 2ea516e636
commit 6d8c0325e4
8 changed files with 92 additions and 65 deletions

View File

@ -4,7 +4,7 @@ import { NostrEvent, ReqFilter, unixNowMs } from "./types";
export class WorkerRelay {
#sqlite?: Sqlite3Static;
#log = (...msg: Array<any>) => console.debug(...msg);
#log = debug("WorkerRelay");
#db?: Database;
/**
@ -169,7 +169,7 @@ export class WorkerRelay {
* Get a summary about events table
*/
summary() {
const res = this.#db?.exec("select kind, count(*) from events group by kind order by 2 desc", {
const res = this.#db?.exec("select kind, count(*) from events group by kind", {
returnValue: "resultRows",
});
return Object.fromEntries(res?.map(a => [String(a[0]), a[1] as number]) ?? []);