{
  "name": "WF-32 run_status",
  "nodes": [
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "limit",
              "type": "string"
            }
          ]
        }
      },
      "id": "trigger",
      "name": "WF Input",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "select id, trigger, scope, started_at, finished_at, status, urls_found, urls_new, urls_scraped, items_created, error from runs order by started_at desc limit coalesce(nullif($1,'')::int, 5)",
        "options": {
          "queryReplacement": "={{ $json.limit || '' }}"
        }
      },
      "id": "select",
      "name": "Select runs",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.4,
      "position": [
        220,
        0
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const rows = $input.all().map(i => i.json).filter(j => j && j.id);\nif (!rows.length) return [{ json: { count: 0, runs: [], note: 'no runs recorded yet' } }];\nreturn [{ json: { count: rows.length, runs: rows } }];"
      },
      "id": "shape",
      "name": "Shape result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        0
      ]
    }
  ],
  "connections": {
    "WF Input": {
      "main": [
        [
          {
            "node": "Select runs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select runs": {
      "main": [
        [
          {
            "node": "Shape result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "errorWorkflow": "PNJMA4NbQGmp1xKv"
  }
}