{
  "name": "bronze",
  "nodes": [
    {
      "parameters": {
        "url": "http://api:3000/people/v1/enrichments",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "page",
              "value": "={{ $json.page }}"
            },
            {
              "name": "limit",
              "value": "={{ $json.limit }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        608,
        0
      ],
      "id": "b650cc22-f3c3-4305-afcb-fb5bb0d1598a",
      "name": "HTTP Request",
      "retryOnFail": true,
      "maxTries": 5,
      "waitBetweenTries": 2000,
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "data",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        816,
        0
      ],
      "id": "3504daec-9144-437f-bc7d-baa203b58ac5",
      "name": "Split Out"
    },
    {
      "parameters": {
        "operation": "upsert",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "bronze",
          "mode": "list",
          "cachedResultName": "bronze"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [
            "id"
          ],
          "schema": [
            {
              "id": "id",
              "displayName": "id",
              "required": true,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "id_workspace",
              "displayName": "id_workspace",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false
            },
            {
              "id": "workspace_name",
              "displayName": "workspace_name",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false
            },
            {
              "id": "total_contacts",
              "displayName": "total_contacts",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": false
            },
            {
              "id": "contact_type",
              "displayName": "contact_type",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false
            },
            {
              "id": "status",
              "displayName": "status",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "options",
              "canBeUsedToMatch": false,
              "options": [
                {
                  "name": "CANCELED",
                  "value": "CANCELED"
                },
                {
                  "name": "FAILED",
                  "value": "FAILED"
                },
                {
                  "name": "COMPLETED",
                  "value": "COMPLETED"
                },
                {
                  "name": "PROCESSING",
                  "value": "PROCESSING"
                }
              ]
            },
            {
              "id": "created_at",
              "displayName": "created_at",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "canBeUsedToMatch": false
            },
            {
              "id": "updated_at",
              "displayName": "updated_at",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "canBeUsedToMatch": false
            },
            {
              "id": "dw_ingested_at",
              "displayName": "dw_ingested_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "canBeUsedToMatch": false
            },
            {
              "id": "dw_updated_at",
              "displayName": "dw_updated_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "canBeUsedToMatch": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        1024,
        0
      ],
      "id": "8dbe0a71-608b-4a3c-913f-b4ff64ffa746",
      "name": "Insert or update rows in a table",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "62fa4c87-53da-44e1-be81-a3033de23aa6",
              "name": "page",
              "value": 1,
              "type": "number"
            },
            {
              "id": "425c8225-030d-417d-935d-e8a7048b1ec3",
              "name": "limit",
              "value": 100,
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        416,
        0
      ],
      "id": "0bb63806-febd-41e7-b555-d83acf6c4e48",
      "name": "Edit Fields"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        16,
        256
      ],
      "id": "4da29a81-f4c2-41a4-9ce3-f0561b8a9596",
      "name": "Limit"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "ba1baf2a-b45b-4e2d-81c6-6550abba4916",
              "leftValue": "={{ $('HTTP Request').item.json.meta.current_page }}",
              "rightValue": "={{ $('HTTP Request').item.json.meta.total_pages }}",
              "operator": {
                "type": "number",
                "operation": "lt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        208,
        256
      ],
      "id": "e0cc6e28-d977-418c-8432-fbc277af496b",
      "name": "If"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a91a1f80-5fdb-484f-8270-46154638b09f",
              "name": "page",
              "value": "={{ $('HTTP Request').first().json.meta.current_page + 1 }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        448,
        192
      ],
      "id": "36ba9acc-ec01-4375-97f6-e77e089c3659",
      "name": "Edit Fields1"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "UPDATE estado_pipeline_dw \nSET status = 'PROCESSANDO', data_ultimo_processo = NOW() \nWHERE nome_pipeline = 'bronze';",
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        208,
        0
      ],
      "id": "ea4dd83f-6e36-4af9-8f76-63b1bcb0f812",
      "name": "Execute a SQL query",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "UPDATE estado_pipeline_dw \nSET \n    status = 'CONCLUIDO', \n    data_ultimo_processo = NOW(),\n    total_registros_processados = (SELECT count(*) FROM bronze)\nWHERE nome_pipeline = 'bronze';",
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        448,
        336
      ],
      "id": "14270bb4-9db5-4538-82eb-965125f3910f",
      "name": "Execute a SQL query1",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "inputSource": "passthrough"
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "id": "1ea72911-2764-4230-8862-b31acbd09bde",
      "name": "When Executed by Another Workflow"
    }
  ],
  "connections": {
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Insert or update rows in a table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert or update rows in a table": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Execute a SQL query1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute a SQL query": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute a SQL query1": {
      "main": [
        []
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Execute a SQL query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "5dd3d4c7-e3d2-42f8-a294-cae79da5c2a4",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "DipvZfztbWYQPYDZ",
  "tags": []
}