GetExplorationScript returns the generated script for a completed session
(c *gin.Context)
| 114 | |
| 115 | // GetExplorationScript returns the generated script for a completed session |
| 116 | func (h *Handler) GetExplorationScript(c *gin.Context) { |
| 117 | if h.explorer == nil { |
| 118 | c.JSON(http.StatusServiceUnavailable, gin.H{"error": "AI Explorer is not available"}) |
| 119 | return |
| 120 | } |
| 121 | |
| 122 | sessionID := c.Param("id") |
| 123 | session, ok := h.explorer.GetSession(sessionID) |
| 124 | if !ok { |
| 125 | c.JSON(http.StatusNotFound, gin.H{"error": "session not found"}) |
| 126 | return |
| 127 | } |
| 128 | |
| 129 | if session.GeneratedScript == nil { |
| 130 | c.JSON(http.StatusBadRequest, gin.H{"error": "script not ready yet", "status": session.Status}) |
| 131 | return |
| 132 | } |
| 133 | |
| 134 | c.JSON(http.StatusOK, session.GeneratedScript) |
| 135 | } |
| 136 | |
| 137 | // SaveExplorationScript saves the generated script to the database |
| 138 | func (h *Handler) SaveExplorationScript(c *gin.Context) { |
nothing calls this directly
no test coverage detected