{
  "schemaVersion": "flowdrome.workflow.v1",
  "id": "",
  "name": "Orders — clean, rank & cap",
  "version": "0",
  "status": "draft",
  "nodes": [
    {
      "id": "seed",
      "type": "input.inject",
      "label": "Overnight orders",
      "category": "trigger",
      "config": {
        "contentType": "application/json",
        "payload": [
          {
            "orderId": "A-1001",
            "customer": "Acme",
            "qty": 4,
            "price": 19.5
          },
          {
            "orderId": "A-1001",
            "customer": "Acme",
            "qty": 4,
            "price": 19.5
          },
          {
            "orderId": "A-1002",
            "customer": "Globex",
            "qty": 1,
            "price": 249
          },
          {
            "orderId": "A-1003",
            "customer": "Initech",
            "qty": 12,
            "price": 3.75
          },
          {
            "orderId": "A-1004",
            "customer": "Umbrella",
            "qty": 2,
            "price": 99
          }
        ]
      },
      "position": {
        "x": 0,
        "y": 0
      }
    },
    {
      "id": "total",
      "type": "processing.set",
      "label": "Compute total",
      "category": "processing",
      "config": {
        "mode": "manual",
        "assignments": [
          {
            "name": "total",
            "type": "number",
            "value": "{{ $json.qty * $json.price }}"
          }
        ],
        "include": "all",
        "dotNotation": true,
        "ignoreConversionErrors": false
      },
      "position": {
        "x": 530,
        "y": 0
      }
    },
    {
      "id": "dedupe",
      "type": "processing.dedupe",
      "label": "Drop resubmissions",
      "category": "processing",
      "config": {
        "compare": "selectedFields",
        "keep": "first",
        "fields": [
          "orderId"
        ]
      },
      "position": {
        "x": 1060,
        "y": 0
      }
    },
    {
      "id": "rank",
      "type": "processing.sort",
      "label": "Rank by value",
      "category": "processing",
      "config": {
        "keys": [
          {
            "field": "total",
            "order": "desc",
            "type": "number"
          }
        ]
      },
      "position": {
        "x": 1590,
        "y": 0
      }
    },
    {
      "id": "cap",
      "type": "processing.limit",
      "label": "Top 3",
      "category": "processing",
      "config": {
        "count": 3,
        "keep": "first"
      },
      "position": {
        "x": 2120,
        "y": 0
      }
    },
    {
      "id": "out",
      "type": "utility.console",
      "label": "Ops board",
      "category": "utility",
      "config": {
        "message": "Top orders: {{ $json }}"
      },
      "position": {
        "x": 2650,
        "y": 0
      }
    }
  ],
  "edges": [
    {
      "id": "e0",
      "sourceNodeId": "seed",
      "sourcePort": "output",
      "targetNodeId": "total",
      "targetPort": "input"
    },
    {
      "id": "e1",
      "sourceNodeId": "total",
      "sourcePort": "output",
      "targetNodeId": "dedupe",
      "targetPort": "input"
    },
    {
      "id": "e2",
      "sourceNodeId": "dedupe",
      "sourcePort": "output",
      "targetNodeId": "rank",
      "targetPort": "input"
    },
    {
      "id": "e3",
      "sourceNodeId": "rank",
      "sourcePort": "output",
      "targetNodeId": "cap",
      "targetPort": "input"
    },
    {
      "id": "e4",
      "sourceNodeId": "cap",
      "sourcePort": "output",
      "targetNodeId": "out",
      "targetPort": "input"
    }
  ],
  "triggers": [
    {
      "id": "t0",
      "nodeId": "seed"
    }
  ],
  "meta": {
    "snippets": [],
    "source": "template-gallery",
    "description": "A morning orders feed, tidied for the ops board: compute each order's total, drop duplicate submissions, rank by value and keep the top three. Swap the Inject for your real order source."
  }
}