fix(server): missing query cache
This commit is contained in:
@@ -11,7 +11,7 @@ export type CreateBlobInput = Prisma.BlobUncheckedCreateInput;
|
||||
@Injectable()
|
||||
export class BlobModel extends BaseModel {
|
||||
async upsert(blob: CreateBlobInput) {
|
||||
return await this.db.blob.upsert({
|
||||
const result = await this.db.blob.upsert({
|
||||
where: {
|
||||
workspaceId_key: {
|
||||
workspaceId: blob.workspaceId,
|
||||
@@ -33,6 +33,8 @@ export class BlobModel extends BaseModel {
|
||||
uploadId: blob.uploadId,
|
||||
},
|
||||
});
|
||||
await this.markQuotaStateStale(blob.workspaceId);
|
||||
return result;
|
||||
}
|
||||
|
||||
async delete(workspaceId: string, key: string, permanently = false) {
|
||||
@@ -43,6 +45,7 @@ export class BlobModel extends BaseModel {
|
||||
key,
|
||||
},
|
||||
});
|
||||
await this.markQuotaStateStale(workspaceId);
|
||||
this.logger.log(`deleted blob ${workspaceId}/${key} permanently`);
|
||||
return;
|
||||
}
|
||||
@@ -58,6 +61,7 @@ export class BlobModel extends BaseModel {
|
||||
deletedAt: new Date(),
|
||||
},
|
||||
});
|
||||
await this.markQuotaStateStale(workspaceId);
|
||||
}
|
||||
|
||||
async get(workspaceId: string, key: string) {
|
||||
@@ -109,4 +113,11 @@ export class BlobModel extends BaseModel {
|
||||
|
||||
return sum._sum.size ?? 0;
|
||||
}
|
||||
|
||||
private async markQuotaStateStale(workspaceId: string) {
|
||||
await this.db.effectiveWorkspaceQuotaState.updateMany({
|
||||
where: { workspaceId },
|
||||
data: { stale: true },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export type CreateCommentAttachmentInput =
|
||||
@Injectable()
|
||||
export class CommentAttachmentModel extends BaseModel {
|
||||
async upsert(input: CreateCommentAttachmentInput) {
|
||||
return await this.db.commentAttachment.upsert({
|
||||
const result = await this.db.commentAttachment.upsert({
|
||||
where: {
|
||||
workspaceId_docId_key: {
|
||||
workspaceId: input.workspaceId,
|
||||
@@ -35,6 +35,8 @@ export class CommentAttachmentModel extends BaseModel {
|
||||
createdBy: input.createdBy,
|
||||
},
|
||||
});
|
||||
await this.markQuotaStateStale(input.workspaceId);
|
||||
return result;
|
||||
}
|
||||
|
||||
async delete(workspaceId: string, docId: string, key: string) {
|
||||
@@ -45,6 +47,7 @@ export class CommentAttachmentModel extends BaseModel {
|
||||
key,
|
||||
},
|
||||
});
|
||||
await this.markQuotaStateStale(workspaceId);
|
||||
this.logger.log(`deleted comment attachment ${workspaceId}/${key}`);
|
||||
}
|
||||
|
||||
@@ -68,4 +71,11 @@ export class CommentAttachmentModel extends BaseModel {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private async markQuotaStateStale(workspaceId: string) {
|
||||
await this.db.effectiveWorkspaceQuotaState.updateMany({
|
||||
where: { workspaceId },
|
||||
data: { stale: true },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user