mirror of
https://github.com/rishikanthc/Scriberr.git
synced 2026-06-30 07:46:16 +00:00
- GetTranscript returns 200 with available=false when transcript not ready - GetJobExecutionData returns 200 with available=false when no execution - GetJobLogs returns JSON with available=false when no logs exist - Updated frontend hooks to handle new response format with available field - Added .gitignore entries for prompt.txt and .agent folder
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package api
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"path/filepath"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// GetJobLogs returns the transcription logs for a specific job
|
|
// @Summary Get transcription logs
|
|
// @Description Get the raw transcription logs for a job
|
|
// @Tags transcription
|
|
// @Produce text/plain
|
|
// @Param id path string true "Job ID"
|
|
// @Success 200 {string} string "Log content"
|
|
// @Failure 404 {object} ErrorResponse
|
|
// @Failure 500 {object} ErrorResponse
|
|
// @Router /transcription/{id}/logs [get]
|
|
func (h *Handler) GetJobLogs(c *gin.Context) {
|
|
jobID := c.Param("id")
|
|
|
|
// Construct path to log file
|
|
logPath := filepath.Join(h.config.TranscriptsDir, jobID, "transcription.log")
|
|
|
|
// Check if file exists
|
|
exists, err := h.fileService.FileExists(logPath)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": fmt.Sprintf("Failed to check logs: %v", err)})
|
|
return
|
|
}
|
|
if !exists {
|
|
// Return graceful empty response instead of 404
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"job_id": jobID,
|
|
"available": false,
|
|
"content": "",
|
|
"message": "No logs available for this job",
|
|
})
|
|
return
|
|
}
|
|
|
|
// Read file content
|
|
content, err := h.fileService.ReadFile(logPath)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": fmt.Sprintf("Failed to read logs: %v", err)})
|
|
return
|
|
}
|
|
|
|
// Return as JSON with content for consistency
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"job_id": jobID,
|
|
"available": true,
|
|
"content": string(content),
|
|
})
|
|
}
|