4.6.7 first pr (#726)
This commit is contained in:
31
packages/service/support/wallet/sub/utils.ts
Normal file
31
packages/service/support/wallet/sub/utils.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { SubStatusEnum } from '@fastgpt/global/support/wallet/sub/constants';
|
||||
import { MongoTeamSub } from './schema';
|
||||
|
||||
/* get team dataset size */
|
||||
export const getTeamDatasetValidSub = async ({
|
||||
teamId,
|
||||
freeSize = Infinity
|
||||
}: {
|
||||
teamId: string;
|
||||
freeSize?: number;
|
||||
}) => {
|
||||
const sub = await MongoTeamSub.findOne({
|
||||
teamId,
|
||||
status: SubStatusEnum.active
|
||||
})
|
||||
.sort({
|
||||
expiredTime: -1
|
||||
})
|
||||
.lean();
|
||||
|
||||
const maxSize = (() => {
|
||||
if (!sub || !sub.datasetStoreAmount) return freeSize;
|
||||
|
||||
return sub.datasetStoreAmount + freeSize;
|
||||
})();
|
||||
|
||||
return {
|
||||
maxSize,
|
||||
sub
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user