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
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used for cancellation and deadlines. |
| taskModels | []*models.Task | A slice of database task models to be converted. |
| latestRuns | map[models.TaskName]*models.Action | A 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
| Type | Description |
|---|---|
([]*task.Task, error) | A slice of task.Task objects and an error if the conversion fails. |