{
  "id": "BtFTzIvfspiU5LSJ",
  "createdAt": "2023-07-13T03:35:14.625Z",
  "updatedAt": "2023-07-13T06:25:59.715Z",
  "name": "[Gus] Append to GSheets subworkflow",
  "active": false,
  "nodes": [
    {
      "id": "6fa18e6c-f534-4fbd-bb99-aaeffb219175",
      "name": "append rows",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1380,
        540
      ],
      "parameters": {
        "options": {},
        "dataMode": "autoMapInputData",
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 676534839,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ujRe-V0vEA_fF-ZzUZx5IQ_Wn7bthqwINEB54QdKilM/edit#gid=676534839",
          "cachedResultName": "investments"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ujRe-V0vEA_fF-ZzUZx5IQ_Wn7bthqwINEB54QdKilM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ujRe-V0vEA_fF-ZzUZx5IQ_Wn7bthqwINEB54QdKilM/edit?usp=drivesdk",
          "cachedResultName": "test_loans_admin_cl"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "typeVersion": 3
    },
    {
      "id": "2908d971-d57a-4d46-999d-8a44924beb6c",
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "position": [
        1380,
        140
      ],
      "parameters": {
        "options": {},
        "keepOnlySet": true
      },
      "executeOnce": true,
      "typeVersion": 2
    },
    {
      "id": "739558d1-e2f3-46d4-8e70-ec0b3a2fa192",
      "name": "MySQL",
      "type": "n8n-nodes-base.mySql",
      "position": [
        920,
        320
      ],
      "parameters": {
        "query": "=select i.id                                                                     as investment_id,\n       1                                                                        as platform_id,\n       \"person\"                                                                 as owner_type,\n       TRIM(UPPER(REPLACE(REPLACE(REPLACE(p.rut, \" \", \"\"), \"-\", \"\"), \".\", \"\"))) as owner_document_number,\n       concat(COALESCE(p.names, \"\"), \" \", COALESCE(p.father_surname, \"\"), \" \",\n              COALESCE(p.mother_surname, \"\"))                                      owner_name,\n       CONVERT_TZ(i.created_at, \"UTC\", \"America/Santiago\")                      as created_at,\n       i.amount,\n       i.funding_request_id                                                     as operation_id,\n       i.state,\n       i.real_rate                                                              as tir,\n       COALESCE(CAST(i.fee AS DECIMAL(14,2)),0)                                 as fee\nfrom investments i\n         inner join profiles p on i.investable_id = p.id and i.investable_type = \"Profile\"\nwhere state in\n      (\"active\", \"paid\", \"legal_collection_completed\", \"legal_collection\", \"waiting_completion\",\n       \"completed\")\nlimit  {{$node[\"Start\"].data[\"start\"]}}  ,10000",
        "operation": "executeQuery"
      },
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "a174c693-d6e5-4f35-ae23-e4f63f0bc170",
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "position": [
        700,
        320
      ],
      "parameters": {},
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "b0e36790-52eb-4f36-b862-9d943ca28993",
      "name": "Split In Batches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1140,
        320
      ],
      "parameters": {
        "options": {},
        "batchSize": 1000
      },
      "typeVersion": 2
    },
    {
      "id": "42feedb0-faf5-40e1-b8e4-e1446e0f040c",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1560,
        540
      ],
      "parameters": {
        "unit": "seconds",
        "amount": 0.5
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MySQL": {
      "main": [
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "MySQL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "append rows": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split In Batches": {
      "main": [
        [
          {
            "node": "append rows",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {},
  "staticData": null,
  "versionId": "7e17ebca-ee84-4985-a1d6-00a09640b591",
  "triggerCount": 0,
  "tags": []
}