mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
32 lines
608 B
TypeScript
32 lines
608 B
TypeScript
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
|
|
};
|
|
};
|