posted at for sorting
This commit is contained in:
1 parent
544b7085ed
commit
d3cc44a959
4 files changed
+49
-3
No files matched your search
+9
-2
@@ -31,6 +31,7 @@ export default async function memeService(baseLog: Logger, prisma: PrismaClient,
|
||||
text,
|
||||
tags: tags,
|
||||
attachmentId: a.id,
|
||||
postedAt: a.postedAt,
|
||||
createdAt: undefined,
|
||||
updatedAt: undefined
|
||||
}
|
||||
@@ -42,7 +43,9 @@ export default async function memeService(baseLog: Logger, prisma: PrismaClient,
|
||||
const task = await meili.createIndex('memes', { primaryKey: 'id' })
|
||||
const result = await meili.waitForTask(task.taskUid)
|
||||
log.debug(result);
|
||||
return meili.index('memes')
|
||||
const index = await meili.index('memes')
|
||||
await index.updateSortableAttributes(['postedAt'])
|
||||
return index;
|
||||
}
|
||||
|
||||
// BLOWS IT UP
|
||||
@@ -50,7 +53,8 @@ export default async function memeService(baseLog: Logger, prisma: PrismaClient,
|
||||
const delTask = await meili.deleteIndex('memes')
|
||||
const delResult = await meili.waitForTask(delTask.taskUid)
|
||||
const index = await ensureMeiliIndex()
|
||||
const memes = await prisma.meme.findMany();
|
||||
const memes = (await prisma.meme.findMany())
|
||||
.map(m => ({ ...m, postedAt: m.postedAt.valueOf() }));
|
||||
|
||||
for await (const batch of _.chunk(memes, 1000)) {
|
||||
const task = await index.updateDocuments(batch)
|
||||
@@ -66,6 +70,9 @@ export default async function memeService(baseLog: Logger, prisma: PrismaClient,
|
||||
|
||||
await ensureMeiliIndex();
|
||||
|
||||
// BAM
|
||||
// await resetMeili();
|
||||
|
||||
return {
|
||||
ensureMeiliIndex,
|
||||
resetMeili,
|
||||
|
||||
Reference in new issue
Block a user