|
1 | 1 | import { useState, useMemo, useCallback, useEffect, useRef } from 'react' |
2 | 2 | import { Chess } from 'chess.ts' |
3 | 3 | import { getGameMove } from 'src/api/play/play' |
4 | | -import { submitOpeningDrill } from 'src/api/opening' |
| 4 | +import { logOpeningDrill } from 'src/api/opening' |
5 | 5 | import { useTreeController } from '../useTreeController' |
6 | 6 | import { useLocalStorage } from '../useLocalStorage' |
7 | 7 | import { |
@@ -530,21 +530,20 @@ export const useOpeningDrillController = ( |
530 | 530 | currentMove: 'Preparing analysis...', |
531 | 531 | }) |
532 | 532 |
|
533 | | - // Submit drill data to backend if session ID is available |
534 | | - if (configuration.sessionId) { |
535 | | - try { |
536 | | - await submitOpeningDrill({ |
537 | | - session_id: configuration.sessionId, |
538 | | - opening_fen: drillGame.selection.variation |
539 | | - ? drillGame.selection.variation.fen |
540 | | - : drillGame.selection.opening.fen, |
541 | | - side_played: drillGame.selection.playerColor, |
542 | | - moves_played_uci: drillGame.moves, |
543 | | - }) |
544 | | - } catch (error) { |
545 | | - console.error('Failed to submit drill to backend:', error) |
546 | | - // Continue even if backend submission fails |
547 | | - } |
| 533 | + // Submit drill data to backend |
| 534 | + try { |
| 535 | + await logOpeningDrill({ |
| 536 | + opening_fen: drillGame.selection.variation |
| 537 | + ? drillGame.selection.variation.fen |
| 538 | + : drillGame.selection.opening.fen, |
| 539 | + side_played: drillGame.selection.playerColor, |
| 540 | + opponent: drillGame.selection.maiaVersion, |
| 541 | + num_moves: drillGame.selection.targetMoveNumber, |
| 542 | + moves_played_uci: drillGame.moves, |
| 543 | + }) |
| 544 | + } catch (error) { |
| 545 | + console.error('Failed to log drill to backend:', error) |
| 546 | + // Continue even if backend submission fails |
548 | 547 | } |
549 | 548 |
|
550 | 549 | // Ensure all positions in the drill are analyzed to sufficient depth |
@@ -593,23 +592,24 @@ export const useOpeningDrillController = ( |
593 | 592 | setIsAnalyzingDrill(false) |
594 | 593 | } |
595 | 594 | }, |
596 | | - [currentDrillGame, evaluateDrillPerformance, configuration.sessionId], |
| 595 | + [currentDrillGame, evaluateDrillPerformance], |
597 | 596 | ) |
598 | 597 |
|
599 | 598 | const moveToNextDrill = useCallback(async () => { |
600 | | - // Submit drill data to backend if session ID is available |
601 | | - if (configuration.sessionId && currentDrillGame) { |
| 599 | + // Submit drill data to backend |
| 600 | + if (currentDrillGame) { |
602 | 601 | try { |
603 | | - await submitOpeningDrill({ |
604 | | - session_id: configuration.sessionId, |
| 602 | + await logOpeningDrill({ |
605 | 603 | opening_fen: currentDrillGame.selection.variation |
606 | 604 | ? currentDrillGame.selection.variation.fen |
607 | 605 | : currentDrillGame.selection.opening.fen, |
608 | 606 | side_played: currentDrillGame.selection.playerColor, |
| 607 | + opponent: currentDrillGame.selection.maiaVersion, |
| 608 | + num_moves: currentDrillGame.selection.targetMoveNumber, |
609 | 609 | moves_played_uci: currentDrillGame.moves, |
610 | 610 | }) |
611 | 611 | } catch (error) { |
612 | | - console.error('Failed to submit drill to backend:', error) |
| 612 | + console.error('Failed to log drill to backend:', error) |
613 | 613 | } |
614 | 614 | } |
615 | 615 |
|
|
0 commit comments