| 3 | import * as practiceSessions from './practiceSessions' |
| 4 | |
| 5 | export async function getLocalCollectionStats(collectionId: string) { |
| 6 | const collection = await collections.getLocalCollectionById(collectionId) |
| 7 | const cardList = await cards.getLocalCardsForCollection(collectionId, 5) |
| 8 | const sessionList = await practiceSessions.getLocalPracticeSessions(collectionId, 30) |
| 9 | |
| 10 | return { |
| 11 | collection_info: { |
| 12 | name: collection?.name || '', |
| 13 | total_cards: cardList.length, |
| 14 | total_practice_sessions: sessionList.length, |
| 15 | }, |
| 16 | recent_sessions: sessionList.map((s) => ({ |
| 17 | id: s.id, |
| 18 | created_at: new Date(s.startedAt).toISOString(), |
| 19 | cards_practiced: s.cardsPracticed, |
| 20 | correct_answers: s.correctAnswers, |
| 21 | total_cards: s.totalCards, |
| 22 | is_completed: s.isCompleted, |
| 23 | })), |
| 24 | difficult_cards: cardList.map((card) => ({ |
| 25 | id: card.id, |
| 26 | front: card.front, |
| 27 | total_attempts: 0, |
| 28 | correct_answers: 0, |
| 29 | })), |
| 30 | } |
| 31 | } |