{
  "id": "k8TKvt3NsTxiilKS",
  "createdAt": "2023-12-01T14:59:00.733Z",
  "updatedAt": "2024-01-26T13:00:21.735Z",
  "name": "Base Comite Mora a DW",
  "active": true,
  "nodes": [
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nconst uniqueItems = [];\nconst seenValues = {};\n\nfor (let i = $input.all().length - 1; i >= 0; i--) {\n  const item = $input.all()[i];\n  const rut = item.json['Rut'].toString().replace('k', 'K').replace(/[-.\\n]/g, '');\n  \n  if (!seenValues[rut]) {\n    uniqueItems.unshift(item);\n    seenValues[rut] = true;\n  }\n}\n\nreturn uniqueItems;\n\n\n"
      },
      "id": "1c815fd1-28d9-4940-b63b-d4739f3d692a",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "position": [
        260,
        -40
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=insert into comite_mora (rut, condicion_curse, fecha_comite_mora)\nvalues ('{{ $json[\"rut\"] }}','{{ $json[\"condicion_curse\"] }}','{{ $json[\"fecha_comite_mora\"] }}' )\n\nON DUPLICATE KEY UPDATE condicion_curse = '{{ $json[\"condicion_curse\"] }}', fecha_comite_mora = '{{ $json[\"fecha_comite_mora\"] }}';",
        "options": {}
      },
      "id": "ffde3c75-12b5-4a9d-8d2b-17eec9a3f020",
      "name": "MySQL1",
      "type": "n8n-nodes-base.mySql",
      "position": [
        980,
        -40
      ],
      "typeVersion": 2.1,
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "rut",
              "value": "={{ $json.Rut }}"
            },
            {
              "name": "condicion_curse",
              "value": "={{ $json['Condicion de curse'] }}"
            },
            {
              "name": "fecha_comite_mora",
              "value": "={{ $json.Fecha }}"
            }
          ]
        },
        "options": {}
      },
      "id": "9e9d4651-bf98-4ad4-91b0-cbfc73b3fa7a",
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "position": [
        440,
        -40
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.rut }}",
              "operation": "notEqual",
              "value2": "={{ '' }}"
            }
          ]
        }
      },
      "id": "15de5cc4-7f6c-4b45-8cb1-173405d86a2c",
      "name": "Filter1",
      "type": "n8n-nodes-base.filter",
      "position": [
        620,
        -40
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "hour": 10
            }
          ]
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E/edit?usp=drivesdk",
          "cachedResultName": "CL Panel de Riesgo"
        },
        "sheetName": {
          "__rl": true,
          "value": 449558759,
          "mode": "list",
          "cachedResultName": "Condiciones especiales",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E/edit#gid=449558759"
        },
        "options": {}
      },
      "id": "a6c5e9cf-416c-4443-9c80-5c0df46e469e",
      "name": "Llamar Comite Mora",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        -80,
        -40
      ],
      "typeVersion": 1,
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Code1": {
      "main": [
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "Filter1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter1": {
      "main": [
        [
          {
            "node": "MySQL1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Llamar Comite Mora": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": {
    "node:Llamar Comite Mora": {
      "documentId": "1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E",
      "sheetId": 449558759,
      "lastRevision": 10330,
      "lastRevisionLink": "https://docs.google.com/spreadsheets/export?id=1gfL6x1A6n2lbKuqaNrj-44lKxyX3HOLXtfoLcFONl6E&revision=10330&exportFormat=xlsx"
    }
  },
  "versionId": "641ecc4f-0377-4515-b6cf-fc94fa153357",
  "triggerCount": 1,
  "tags": []
}