Content-Length: 7718 | pFad | http://github.com/coder/coder/pull/18919.diff
thub.com diff --git a/coderd/aitasks.go b/coderd/aitasks.go index a982ccc39b26b..6d91098b63a81 100644 --- a/coderd/aitasks.go +++ b/coderd/aitasks.go @@ -61,3 +61,19 @@ func (api *API) aiTasksPrompts(rw http.ResponseWriter, r *http.Request) { Prompts: promptsByBuildID, }) } + +// This endpoint is experimental and not guaranteed to be stable, so we're not +// generating public-facing documentation for it. +func (api *API) aiTasksStats(rw http.ResponseWriter, r *http.Request) { + ctx := r.Context() + _ = api // Suppress unused receiver warning + + stats := codersdk.AITasksStatsResponse{ + ActiveTasks: 3, + CompletedTasks: 15, + FailedTasks: 2, + TotalWorkspacesWithTasks: 8, + } + + httpapi.Write(ctx, rw, http.StatusOK, stats) +} diff --git a/coderd/coderd.go b/coderd/coderd.go index c3c1fb09cc6cc..89572ada29fba 100644 --- a/coderd/coderd.go +++ b/coderd/coderd.go @@ -979,6 +979,7 @@ func New(options *Options) *API { r.Use(apiKeyMiddleware) r.Route("/aitasks", func(r chi.Router) { r.Get("/prompts", api.aiTasksPrompts) + r.Get("/stats", api.aiTasksStats) }) r.Route("/mcp", func(r chi.Router) { r.Use( diff --git a/codersdk/aitasks.go b/codersdk/aitasks.go index 89ca9c948f272..3876db0e07d28 100644 --- a/codersdk/aitasks.go +++ b/codersdk/aitasks.go @@ -18,6 +18,13 @@ type AITasksPromptsResponse struct { Prompts map[string]string `json:"prompts"` } +type AITasksStatsResponse struct { + ActiveTasks int `json:"active_tasks"` + CompletedTasks int `json:"completed_tasks"` + FailedTasks int `json:"failed_tasks"` + TotalWorkspacesWithTasks int `json:"total_workspaces_with_tasks"` +} + // AITaskPrompts returns prompts for multiple workspace builds by their IDs. func (c *ExperimentalClient) AITaskPrompts(ctx context.Context, buildIDs []uuid.UUID) (AITasksPromptsResponse, error) { if len(buildIDs) == 0 { diff --git a/site/src/api/api.ts b/site/src/api/api.ts index 013c018d5c656..34d5eb6451ff4 100644 --- a/site/src/api/api.ts +++ b/site/src/api/api.ts @@ -2596,6 +2596,13 @@ class ApiMethods { markAllInboxNotificationsAsRead = async () => { await this.axios.putFetched URL: http://github.com/coder/coder/pull/18919.diff
Alternative Proxies: