voices
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (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

This commit is contained in:
Dmitry 2025-12-19 05:42:08 +03:00
parent 078a4ea22b
commit d8a29eb84a
3 changed files with 35 additions and 8 deletions

View file

@ -867,6 +867,7 @@ class AdminCardsApiV2 {
final objectId = requestDto.voiceUrl;
// Create voice record with object ID
print('🔍 addCardVoice: Creating voice record with objectId $objectId for card $cardId');
final voiceId = await _db.packDao.createVoice(
VoiceModelsCompanion.insert(
cardId: cardId,
@ -874,9 +875,12 @@ class AdminCardsApiV2 {
language: requestDto.language ?? 'en',
),
);
print('✅ addCardVoice: Created voice record with id $voiceId');
// Link voice to card
print('🔍 addCardVoice: Linking voice $voiceId to card $cardId');
await _db.packDao.addVoiceToCard(cardId, voiceId);
print('✅ addCardVoice: Successfully linked voice $voiceId to card $cardId');
final voice = await _db.packDao.getVoiceById(voiceId);

View file

@ -628,7 +628,9 @@ class PacksApiV2 {
// Get voices for card
final voices = await _db.packDao.getCardVoices(cardId);
print('🔍 getCardVoices: Found ${voices.length} voices for card $cardId');
if (voices.isEmpty) {
print('⚠️ getCardVoices: No voices found for card $cardId');
return _ok({'items': <Map<String, Object?>>[]});
}

View file

@ -281,6 +281,17 @@ class PackDao extends DatabaseAccessor<AppDatabase> with _$PackDaoMixin {
/// Получить голосовые модели карточки
Future<List<VoiceModel>> getCardVoices(String cardId) async {
print('🔍 DAO getCardVoices: Querying voices for card $cardId');
// First, check if there are any voices in CardVoices table for this card
final countExpr = cardVoices.cardId.count();
final countQuery = selectOnly(cardVoices)
..addColumns([countExpr])
..where(cardVoices.cardId.equals(cardId));
final countResult = await countQuery.getSingle();
final count = countResult.read(countExpr) ?? 0;
print('🔍 DAO getCardVoices: Found $count entries in CardVoices table for card $cardId');
final query = select(voiceModels).join([
innerJoin(
cardVoices,
@ -289,18 +300,28 @@ class PackDao extends DatabaseAccessor<AppDatabase> with _$PackDaoMixin {
),
]);
return query.map((row) => row.readTable(voiceModels)).get();
final result = await query.map((row) => row.readTable(voiceModels)).get();
print('🔍 DAO getCardVoices: Query returned ${result.length} voices');
return result;
}
/// Добавить голосовую модель к карточке
Future<void> addVoiceToCard(String cardId, String voiceId) async {
await into(cardVoices).insert(
CardVoicesCompanion.insert(
cardId: cardId,
voiceId: voiceId,
),
mode: InsertMode.insertOrIgnore,
);
print('🔍 DAO addVoiceToCard: Linking voice $voiceId to card $cardId');
try {
await into(cardVoices).insert(
CardVoicesCompanion.insert(
cardId: cardId,
voiceId: voiceId,
),
mode: InsertMode.insertOrIgnore,
);
print('✅ DAO addVoiceToCard: Successfully linked voice $voiceId to card $cardId');
} catch (e) {
print('❌ DAO addVoiceToCard: Error linking voice $voiceId to card $cardId: $e');
rethrow;
}
}
/// Удалить голосовую модель из карточки