Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lifegpc committed Jun 6, 2024
1 parent e59716f commit 8234cc3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions meilisearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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<EnqueuedTask>) {
if (task instanceof Promise) {
Expand Down
8 changes: 8 additions & 0 deletions routes/api/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion task_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8234cc3

Please sign in to comment.