# Scénario: Détail d'un statut
name: statuses_show
version: "1.0"
description: Retourne un statut avec le nombre de tâches

input:
  required:
    - id
  validation:
    id:
      type: int

steps:
  - id: get_status
    service: db
    action: query_one
    params:
      query: "SELECT * FROM statuses WHERE id = ? AND user_id = ?"
      args: ["{{input.id}}", "{{auth.user_id}}"]
    on_error: abort
    error_message: "Statut non trouvé"
    error_status: 404

  - id: count_tasks
    service: db
    action: query_one
    params:
      query: "SELECT COUNT(*) as count FROM tasks WHERE status_id = ?"
      args: ["{{input.id}}"]

output:
  status: 200
  body:
    success: true
    data:
      id: "{{steps.get_status.result.id}}"
      code: "{{steps.get_status.result.code}}"
      name: "{{steps.get_status.result.name}}"
      color: "{{steps.get_status.result.color}}"
      project_id: "{{steps.get_status.result.project_id}}"
      position: "{{steps.get_status.result.position}}"
      task_count: "{{steps.count_tasks.result.count}}"
