Skip to content

Commit

Permalink
Feat: Add the ability to skip outputs and stats retrieval on list query
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun-m committed Jan 10, 2025
1 parent 8375136 commit a5c481b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/api/v1/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"errors"
"net/http"
"strconv"
"time"

"github.com/beam-cloud/beta9/pkg/abstractions/output"
Expand Down Expand Up @@ -78,6 +79,7 @@ func (g *TaskGroup) ListTasksPaginated(ctx echo.Context) error {
if err != nil {
return err
}
skipDetails, _ := strconv.ParseBool(ctx.QueryParam("skip_details"))

workspace, err := g.backendRepo.GetWorkspaceByExternalId(ctx.Request().Context(), ctx.Param("workspaceId"))
if err != nil {
Expand All @@ -87,10 +89,12 @@ func (g *TaskGroup) ListTasksPaginated(ctx echo.Context) error {
if tasks, err := g.backendRepo.ListTasksWithRelatedPaginated(ctx.Request().Context(), *filters); err != nil {
return HTTPInternalServerError("Failed to list tasks")
} else {
for i := range tasks.Data {
tasks.Data[i].Stub.SanitizeConfig()
g.addOutputsToTask(ctx.Request().Context(), workspace.Name, &tasks.Data[i])
g.addStatsToTask(ctx.Request().Context(), workspace.Name, &tasks.Data[i])
if !skipDetails {
for i := range tasks.Data {
tasks.Data[i].Stub.SanitizeConfig()
g.addOutputsToTask(ctx.Request().Context(), workspace.Name, &tasks.Data[i])
g.addStatsToTask(ctx.Request().Context(), workspace.Name, &tasks.Data[i])
}
}
return ctx.JSON(http.StatusOK, tasks)
}
Expand Down

0 comments on commit a5c481b

Please sign in to comment.