mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-15 09:06:19 +08:00
feat: integrate user usage into apis (#5075)
This commit is contained in:
@@ -3,34 +3,6 @@ import { Module } from '@nestjs/common';
|
||||
import { PrismaService } from '../../prisma';
|
||||
import { FeatureService } from './configure';
|
||||
import { FeatureManagementService } from './feature';
|
||||
import type { CommonFeature } from './types';
|
||||
|
||||
// upgrade features from lower version to higher version
|
||||
async function upsertFeature(
|
||||
db: PrismaService,
|
||||
feature: CommonFeature
|
||||
): Promise<void> {
|
||||
const hasEqualOrGreaterVersion =
|
||||
(await db.features.count({
|
||||
where: {
|
||||
feature: feature.feature,
|
||||
version: {
|
||||
gte: feature.version,
|
||||
},
|
||||
},
|
||||
})) > 0;
|
||||
// will not update exists version
|
||||
if (!hasEqualOrGreaterVersion) {
|
||||
await db.features.create({
|
||||
data: {
|
||||
feature: feature.feature,
|
||||
type: feature.type,
|
||||
version: feature.version,
|
||||
configs: feature.configs,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Feature module provider pre-user feature flag management.
|
||||
@@ -46,9 +18,4 @@ export class FeatureModule {}
|
||||
|
||||
export type { CommonFeature, Feature } from './types';
|
||||
export { FeatureKind, Features, FeatureType } from './types';
|
||||
export {
|
||||
FeatureManagementService,
|
||||
FeatureService,
|
||||
PrismaService,
|
||||
upsertFeature,
|
||||
};
|
||||
export { FeatureManagementService, FeatureService, PrismaService };
|
||||
|
||||
Reference in New Issue
Block a user