There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat: skip update quota if same as latest activated quota (#5631)
DarkSkyae8401b6f468
diff --git a/packages/backend/server/src/modules/quota/service.ts b/packages/backend/server/src/modules/quota/service.tsindex 5f05a59e57..d316374276 100644--- a/packages/backend/server/src/modules/quota/service.ts+++ b/packages/backend/server/src/modules/quota/service.ts@@ -5,6 +5,8 @@ import { FeatureKind } from '../features';import { QuotaConfig } from './quota';import { QuotaType } from './types';+type Transaction = Parameters<Parameters<PrismaService['$transaction']>[0]>[0];+@Injectable()export class QuotaService {constructor(private readonly prisma: PrismaService) {}@@ -83,6 +85,13 @@ export class QuotaService {expiredAt?: Date) {await this.prisma.$transaction(async tx => {+ const hasSameActivatedQuota = await this.hasQuota(userId, quota, tx);++ if (hasSameActivatedQuota) {+ // don't need to switch+ return;+ }+const latestPlanVersion = await tx.features.aggregate({where: {feature: quota,@@ -130,8 +139,10 @@ export class QuotaService {});}- async hasQuota(userId: string, quota: QuotaType) {- return this.prisma.userFeatures+ async hasQuota(userId: string, quota: QuotaType, transaction?: Transaction) {+ const executor = transaction ?? this.prisma;++ return executor.userFeatures.count({where: {userId,