fix: index all
This commit is contained in:
parent
1402131b9e
commit
7f00bace29
1 changed files with 21 additions and 1 deletions
|
@ -7,7 +7,7 @@ import { MoreThan } from "typeorm";
|
|||
import { index } from "@/services/note/create.js";
|
||||
import { Note } from "@/models/entities/note.js";
|
||||
import meilisearch from "../../../db/meilisearch.js";
|
||||
import { fetchPostCount, scyllaClient } from "@/db/scylla.js";
|
||||
import { fetchPostCount, parseScyllaNote, scyllaClient } from "@/db/scylla.js";
|
||||
|
||||
const logger = queueLogger.createSubLogger("index-all-notes");
|
||||
|
||||
|
@ -21,6 +21,26 @@ export default async function indexAllNotes(
|
|||
let indexedCount: number = (job.data.indexedCount as number) ?? 0;
|
||||
let total: number = (job.data.total as number) ?? 0;
|
||||
|
||||
if (scyllaClient) {
|
||||
total = await fetchPostCount(false);
|
||||
scyllaClient.eachRow("SELECT * FROM note", [], (n, row) => {
|
||||
if (n % 1000 === 0) {
|
||||
job.progress(((n / total) * 100).toFixed(1));
|
||||
logger.info(`Indexed notes ${n}/${total}`);
|
||||
}
|
||||
const note = parseScyllaNote(row);
|
||||
if (meilisearch) {
|
||||
meilisearch.ingestNote([note]).then(() => index(note, true));
|
||||
} else {
|
||||
index(note, true);
|
||||
}
|
||||
});
|
||||
|
||||
done();
|
||||
logger.info("All notes have been indexed.");
|
||||
return;
|
||||
}
|
||||
|
||||
let running = true;
|
||||
const take = 10000;
|
||||
const batch = 100;
|
||||
|
|
Loading…
Reference in a new issue