refactor(server): split HistoryModel from DocModel (#10604)

This commit is contained in:
fengmk2
2025-03-05 12:10:28 +00:00
parent fed0e0add3
commit 687c26304a
9 changed files with 374 additions and 330 deletions

View File

@@ -171,14 +171,14 @@ export class PgWorkspaceDocStorageAdapter extends DocStorageAdapter {
docId: string,
query: HistoryFilter
) {
return await this.models.doc.findHistories(workspaceId, docId, {
return await this.models.history.findMany(workspaceId, docId, {
before: query.before,
take: query.limit,
});
}
async getDocHistory(workspaceId: string, docId: string, timestamp: number) {
const history = await this.models.doc.getHistory(
const history = await this.models.history.get(
workspaceId,
docId,
timestamp
@@ -282,7 +282,7 @@ export class PgWorkspaceDocStorageAdapter extends DocStorageAdapter {
}
try {
await this.models.doc.createHistory(
await this.models.history.create(
{
spaceId: snapshot.spaceId,
docId: snapshot.docId,
@@ -372,7 +372,7 @@ export class PgWorkspaceDocStorageAdapter extends DocStorageAdapter {
}
protected async lastDocHistory(workspaceId: string, id: string) {
return this.models.doc.getLatestHistory(workspaceId, id);
return this.models.history.getLatest(workspaceId, id);
}
// for auto merging

View File

@@ -32,7 +32,7 @@ export class DocStorageCronJob {
@OnJob('nightly.cleanExpiredHistories')
async cleanExpiredHistories() {
await this.models.doc.deleteExpiredHistories();
await this.models.history.cleanExpired();
}
@OnEvent('user.deleted')