fix: TypeScript errors — string→number, activityDate, remove easeFactor from update
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s

- import-candidate: explicit any[] type for safeCandidates
- growth: date→activityDate (actual DailyLearningActivity field name)
- review: Number(rating) for SM-2 math, remove easeFactor from updateCard call

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
WangDL 2026-05-24 14:25:54 +08:00
parent 3f2ba8ba93
commit 4be418ef4a
3 changed files with 7 additions and 9 deletions

View File

@ -73,7 +73,7 @@ export class ImportCandidateService {
async createCandidates(userId: string, knowledgeBaseId: string, sourceId: string, importId: string, candidates: Array<any>) { async createCandidates(userId: string, knowledgeBaseId: string, sourceId: string, importId: string, candidates: Array<any>) {
// Filter out unsafe candidates // Filter out unsafe candidates
const safeCandidates = []; const safeCandidates: any[] = [];
for (const c of candidates) { for (const c of candidates) {
const safe = await this.checkSafety(c.title || '', c.content || '', userId); const safe = await this.checkSafety(c.title || '', c.content || '', userId);
if (safe) safeCandidates.push(c); if (safe) safeCandidates.push(c);

View File

@ -11,18 +11,17 @@ export class GrowthService {
async getStreak(userId: string): Promise<{ currentStreak: number; longestStreak: number }> { async getStreak(userId: string): Promise<{ currentStreak: number; longestStreak: number }> {
const activities = await this.prisma.dailyLearningActivity.findMany({ const activities = await this.prisma.dailyLearningActivity.findMany({
where: { userId }, where: { userId },
orderBy: { date: 'desc' }, orderBy: { activityDate: 'desc' },
select: { date: true }, select: { activityDate: true },
take: 365, take: 365,
}); });
if (activities.length === 0) return { currentStreak: 0, longestStreak: 0 }; if (activities.length === 0) return { currentStreak: 0, longestStreak: 0 };
// Dedupe by date
const seen = new Set<string>(); const seen = new Set<string>();
const dates: string[] = []; const dates: string[] = [];
for (const a of activities) { for (const a of activities) {
const d = new Date(a.date).toISOString().slice(0, 10); const d = new Date(a.activityDate).toISOString().slice(0, 10);
if (!seen.has(d)) { seen.add(d); dates.push(d); } if (!seen.has(d)) { seen.add(d); dates.push(d); }
} }
let currentStreak = dates.length > 0 ? 1 : 0; let currentStreak = dates.length > 0 ? 1 : 0;

View File

@ -26,7 +26,7 @@ export class ReviewService {
if (!card) throw new NotFoundException(`Review card ${id} not found`); if (!card) throw new NotFoundException(`Review card ${id} not found`);
// Anki SM-2 algorithm // Anki SM-2 algorithm
const rating = dto.rating; const rating = Number(dto.rating);
let intervalDays = Number(card.intervalDays) || 1; let intervalDays = Number(card.intervalDays) || 1;
let easeFactor = Number(card.easeFactor) || EASE_FACTOR_DEFAULT; let easeFactor = Number(card.easeFactor) || EASE_FACTOR_DEFAULT;
let repetitionCount = Number(card.repetitionCount) || 0; let repetitionCount = Number(card.repetitionCount) || 0;
@ -55,12 +55,11 @@ export class ReviewService {
const nextReviewAt = new Date(Date.now() + intervalDays * 86400000); const nextReviewAt = new Date(Date.now() + intervalDays * 86400000);
const log = await this.reviewRepository.insertLog({ const log = await this.reviewRepository.insertLog({
userId, reviewCardId: id, rating, responseText: dto.responseText, userId, reviewCardId: id, rating: dto.rating, responseText: dto.responseText,
}); });
await this.reviewRepository.updateCard(id, { await this.reviewRepository.updateCard(id, {
status: 'active', nextReviewAt, intervalDays, easeFactor, status: 'active', nextReviewAt, intervalDays, repetitionCount, lapseCount,
repetitionCount, lapseCount,
}); });
return { log, nextReviewAt, scheduleState, intervalDays }; return { log, nextReviewAt, scheduleState, intervalDays };