MCPcopy Create free account
hub / github.com/tbphp/gpt-load / GetTaskStatus

Method GetTaskStatus

internal/services/task_service.go:80–99  ·  view source on GitHub ↗

GetTaskStatus returns the current status of the task.

()

Source from the content-addressed store, hash-verified

78
79// GetTaskStatus returns the current status of the task.
80func (s *TaskService) GetTaskStatus() (*TaskStatus, error) {
81 statusBytes, err := s.store.Get(globalTaskKey)
82 if err != nil {
83 if errors.Is(err, store.ErrNotFound) {
84 return &TaskStatus{IsRunning: false}, nil
85 }
86 return nil, fmt.Errorf("failed to get task status: %w", err)
87 }
88
89 var status TaskStatus
90 if err := json.Unmarshal(statusBytes, &status); err != nil {
91 return nil, fmt.Errorf("failed to deserialize task status: %w", err)
92 }
93
94 if !status.IsRunning && status.FinishedAt != nil {
95 status.DurationSeconds = status.FinishedAt.Sub(status.StartedAt).Seconds()
96 }
97
98 return &status, nil
99}
100
101// UpdateProgress updates the progress of the current task.
102func (s *TaskService) UpdateProgress(processed int) error {

Callers 3

StartTaskMethod · 0.95
UpdateProgressMethod · 0.95
EndTaskMethod · 0.95

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected