(chatId: string)
| 348 | ORDER BY created_at DESC LIMIT 1 |
| 349 | `); |
| 350 | return stmt.get(chatId) as any; |
| 351 | } |
| 352 | |
| 353 | function addParticipantToLottery(lotteryId: number, participant: any): boolean { |
| 354 | if (!db) return false; |
| 355 | |
| 356 | try { |
| 357 | // Use transaction for concurrent safety |
| 358 | const transaction = db.transaction(() => { |
| 359 | // Check current participant count |
| 360 | const countStmt = db.prepare(`SELECT COUNT(*) as count FROM lottery_participants WHERE lottery_id = ?`); |
| 361 | const countResult = countStmt.get(lotteryId) as { count: number } | undefined; |
| 362 | const currentCount = countResult?.count || 0; |
no test coverage detected