Skip to main content

TaskModelsToTasks

Converts a slice of task models into a slice of simplified task.Task objects, enriching them with metadata and optionally with information about their latest runs.

def TaskModelsToTasks(
ctx: context.Context,
taskModels: []*models.Task,
latestRuns: map[models.TaskName]*models.Action
) - > ([]*task.Task, error)

Converts a slice of task models to a slice of simplified task.Task objects, using task.TaskDetails as an intermediate step. This function is used to transform database-centric task representations into a format suitable for API consumption.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, used for cancellation and deadlines.
taskModels[]*models.TaskA slice of database task models to be converted.
latestRunsmap[models.TaskName]*models.ActionA map containing the latest run information for tasks, keyed by task name. This is used to enrich the task.Task objects with their most recent execution details.

Returns

TypeDescription
([]*task.Task, error)A slice of task.Task objects and an error if the conversion fails.