Archer 379673cae1
fix colection create api (#766)
Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
2024-01-23 09:01:24 +08:00

29 lines
615 B
TypeScript

import { SubTypeEnum } 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,
type: SubTypeEnum.extraDatasetSize,
expiredTime: { $gte: new Date() }
}).lean();
const maxSize = (() => {
if (!sub || !sub.currentExtraDatasetSize) return freeSize;
return sub.currentExtraDatasetSize + freeSize;
})();
return {
maxSize,
sub
};
};