Merge pull request #4709 from toeverything/61/doc-perf

perf(server): opmitize updates table
This commit is contained in:
LongYinan
2023-10-30 09:27:19 +00:00
committed by GitHub
3 changed files with 19 additions and 7 deletions

View File

@@ -254,15 +254,15 @@ export class DocManager implements OnModuleInit, OnModuleDestroy {
* get pending updates
*/
async getUpdates(workspaceId: string, guid: string) {
return this.db.update.findMany({
const updates = await this.db.update.findMany({
where: {
workspaceId,
id: guid,
},
orderBy: {
seq: 'asc',
},
});
// perf(memory): avoid sorting in db
return updates.sort((a, b) => (a.createdAt < b.createdAt ? -1 : 1));
}
/**