mnemo_cards/mnemo_cards_backend/lib/user/user_data_model.dart
Dmitry 336bafc600
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Web App CI / test (push) Waiting to run
Web App CI / build (push) Blocked by required conditions
Deploy Admin Panel / Deploy Admin Panel (push) Waiting to run
Deploy Admin Panel / Admin Panel Verification (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Deploy Telegram Bot / Deploy Telegram Bot (push) Waiting to run
tasks and stuff
2026-01-09 20:21:18 +03:00

45 lines
1.8 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:mnemo_cards_common_backend/mnemo_cards_common_backend.dart';
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
extension UserDataModelExtension on UserDataModel {
/// Конвертация в DTO с использованием данных из модели
///
/// Примечание: packProgress, studyDates, categoryMinutes теперь рассчитываются на лету
/// и должны передаваться как параметры
UserDataDto toDto({
List<PackProgressDto>? calculatedPackProgress,
List<DateTime>? calculatedStudyDates,
Map<String, int>? calculatedCategoryMinutes,
AllWordsStatisticsDto? calculatedWordsStatistics,
}) {
return UserDataDto(
allWordsStatistics:
calculatedWordsStatistics ??
AllWordsStatisticsDto(
words: words.map((model) => model.toDto()).toList(),
),
allTestsStatistics: AllTestsStatisticsDto(
tests: {}, // testsStatistics removed - always empty
lastSessionToken: this.lastTestSessionToken,
),
// NEW STATISTICS FIELDS
lastTimeOnline: lastTimeOnline,
totalStudyTimeMinutes: totalStudyTimeMinutes,
currentStreak: currentStreak,
longestStreak: longestStreak,
packProgress: calculatedPackProgress != null
? {
for (final progress in calculatedPackProgress)
progress.packId: progress,
}
: {
for (final progress in packProgress)
progress.packId: progress.toDto(),
},
studyDates: calculatedStudyDates ?? List<DateTime>.from(studyDates),
categoryMinutes:
calculatedCategoryMinutes ?? Map<String, int>.from(categoryMinutes),
achievements: achievements.map((model) => model.toDto()).toList(),
);
}
}