cdrdpyj/scripts/n8n-workflow-translation-re...

173 lines
5.5 KiB
JSON

{
"name": "📊 Reporte de Traducciones - cdrdpyj",
"nodes": [
{
"id": "webhook-1",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1.2,
"position": [250, 300],
"parameters": {
"path": "news-summary",
"httpMethod": "POST",
"authentication": "headerAuth",
"responseMode": "onReceived",
"responseData": "{{ $json }}",
"options": {}
},
"credentials": {
"httpHeaderAuth": {
"id": null,
"name": "crpj-summary-key"
}
}
},
{
"id": "code-1",
"name": "Formatear datos",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [480, 300],
"parameters": {
"language": "javaScript",
"code": "const langNames = {\n es: 'Español',\n en: 'English',\n fr: 'Français',\n pt: 'Português',\n rw: 'Kinyarwanda',\n he: 'עברית',\n uk: 'Українська',\n ru: 'Русский',\n kr: 'Kreyòl',\n};\n\nconst ORDER = ['es', 'en', 'fr', 'pt', 'rw', 'he', 'uk', 'ru', 'kr'];\nconst payload = $input.first().json.body;\n\nconst summaryRows = [];\nfor (const code of ORDER) {\n const s = payload.summary[code];\n if (!s) continue;\n summaryRows.push({\n json: {\n language: langNames[code] || code,\n code,\n totalEs: payload.totals.spanishArticles,\n translated: s.translated,\n missing: s.missing,\n percent: s.percent,\n },\n });\n}\n\nconst detailRows = [];\nconst orphanCount = payload.orphaned?.length || 0;\n\nif (orphanCount > 0) {\n const warnRow = { json: { date: '', spanishTitle: `⚠️ ${orphanCount} archivo(s) huérfano(s) — sin versión en español`, spanishUrl: '' } };\n for (const lang of ORDER) warnRow.json[lang] = '';\n detailRows.push(warnRow);\n}\n\nfor (const art of payload.articles) {\n const row = { json: { date: art.date, spanishTitle: art.spanishTitle, spanishUrl: art.spanishUrl || '' } };\n for (const lang of ORDER) row.json[lang] = art.files[lang] ? '✅' : '❌';\n detailRows.push(row);\n}\n\nfor (const orphan of payload.orphaned) {\n const row = { json: { date: orphan.groupId, spanishTitle: `⚠️ Huérfano: solo en ${orphan.languages.join(', ')}`, spanishUrl: orphan.urls?.[orphan.languages[0]] || '' } };\n for (const lang of ORDER) row.json[lang] = orphan.languages.includes(lang) ? '⚠️' : '—';\n detailRows.push(row);\n}\n\nreturn [summaryRows, detailRows];\n",
"mode": "raw"
},
"nodesOnOutput": {
"main": [
{
"type": "n8n-nodes-base.googleSheets",
"index": [
0
]
},
{
"type": "n8n-nodes-base.googleSheets",
"index": [
1
]
}
]
}
},
{
"id": "sheets-summary",
"name": "Sheets - Resumen",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4,
"position": [720, 180],
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"value": "",
"mode": "id"
},
"sheetName": "Resumen",
"columns": {
"mappingMode": "defineBelow",
"value": {
"A": "={{ $json.language }}",
"B": "={{ $json.code }}",
"C": "={{ $json.totalEs }}",
"D": "={{ $json.translated }}",
"E": "={{ $json.missing }}",
"F": "={{ $json.percent }}"
}
},
"options": {
"cellFormat": "USER_ENTERED",
"dataLocationOnSheet": "A:F"
},
"handshake": false
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": null,
"name": "Google Sheets"
}
}
},
{
"id": "sheets-detail",
"name": "Sheets - Detalle",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4,
"position": [720, 420],
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"value": "",
"mode": "id"
},
"sheetName": "Detalle",
"columns": {
"mappingMode": "defineBelow",
"value": {
"A": "={{ $json.date }}",
"B": "={{ $json.spanishTitle }}",
"C": "={{ $json.spanishUrl }}",
"D": "={{ $json.es }}",
"E": "={{ $json.en }}",
"F": "={{ $json.fr }}",
"G": "={{ $json.pt }}",
"H": "={{ $json.rw }}",
"I": "={{ $json.he }}",
"J": "={{ $json.uk }}",
"K": "={{ $json.ru }}",
"L": "={{ $json.kr }}"
}
},
"options": {
"cellFormat": "USER_ENTERED",
"dataLocationOnSheet": "A:L"
},
"handshake": false
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": null,
"name": "Google Sheets"
}
}
}
],
"connections": {
"Webhook": {
"main": [
[
{
"node": "Formatear datos",
"type": "main",
"index": 0
}
]
]
},
"Formatear datos": {
"main": [
[
{
"node": "Sheets - Resumen",
"type": "main",
"index": 0
}
],
[
{
"node": "Sheets - Detalle",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {},
"staticData": null,
"tags": [],
"versionId": "1.0"
}