feat(ai): 添加AI报告生成历史记录功能,支持每日生成限制和双API提供商
This commit is contained in:
@@ -788,6 +788,37 @@ export class ChallengesService {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户当前参与的活跃挑战数量(正在进行中且未过期)
|
||||
* @param userId 用户ID
|
||||
* @returns 活跃挑战数量
|
||||
*/
|
||||
async getActiveParticipatingChallengeCount(userId: string): Promise<number> {
|
||||
const now = new Date();
|
||||
|
||||
// 查询用户参与的所有活跃状态的挑战
|
||||
const participants = await this.participantModel.findAll({
|
||||
where: {
|
||||
userId,
|
||||
status: {
|
||||
[Op.in]: [ChallengeParticipantStatus.ACTIVE, ChallengeParticipantStatus.COMPLETED],
|
||||
},
|
||||
},
|
||||
include: [{
|
||||
model: Challenge,
|
||||
as: 'challenge',
|
||||
where: {
|
||||
challengeState: ChallengeState.ACTIVE,
|
||||
startAt: { [Op.lte]: now },
|
||||
endAt: { [Op.gte]: now },
|
||||
},
|
||||
required: true,
|
||||
}],
|
||||
});
|
||||
|
||||
return participants.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户加入的自定义挑战 ID 列表
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user