From 8234cc3d4458a3199c93f99623d935c5f760409b Mon Sep 17 00:00:00 2001 From: lifegpc Date: Thu, 6 Jun 2024 16:27:18 +0800 Subject: [PATCH] Fix bug --- meilisearch.ts | 5 +++-- routes/api/task.ts | 8 ++++++++ task_manager.ts | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/meilisearch.ts b/meilisearch.ts index ddaefef..11ce3e3 100644 --- a/meilisearch.ts +++ b/meilisearch.ts @@ -4,7 +4,7 @@ import { MeiliSearch, MeiliSearchApiError, } from "meilisearch"; -import { sleep } from "./utils.ts"; +import { sleep, toJSON } from "./utils.ts"; import type { EhDb } from "./db.ts"; import isEqual from "lodash/isEqual"; @@ -141,7 +141,8 @@ export class MeiliSearchServer { e.tags = this.db.get_gtags_full(gid); return e; }); - await this.waitTask(gmeta.updateDocuments(datas)); + const d = JSON.parse(toJSON(datas)); + await this.waitTask(gmeta.updateDocuments(d)); } async waitTask(task: EnqueuedTask | Promise) { if (task instanceof Promise) { diff --git a/routes/api/task.ts b/routes/api/task.ts index 06348cb..828b966 100644 --- a/routes/api/task.ts +++ b/routes/api/task.ts @@ -157,6 +157,14 @@ export const handler: Handlers = { } catch (e) { return return_error(500, e.message); } + } else if (typ == "update_meili_search_data") { + const gid = await parse_big_int(form.get("gid"), 0); + try { + const task = await t.add_update_meili_search_data_task(gid); + return return_data(task, 201); + } catch (e) { + return return_error(500, e.message); + } } else { return return_error(5, "unknown type"); } diff --git a/task_manager.ts b/task_manager.ts index 39a55b9..78f0e08 100644 --- a/task_manager.ts +++ b/task_manager.ts @@ -157,7 +157,7 @@ export class TaskManager extends EventTarget { }; return await this.#add_task(task); } - async add_update_meili_search_data_task(gid?: number) { + async add_update_meili_search_data_task(gid?: number | bigint) { this.#check_closed(); const otask = await this.db.check_update_meili_search_data_task(gid); if (otask !== undefined) {