{
  "name": "Aceversity — weekly study digest",
  "nodes": [
    {
      "parameters": {
        "rule": { "interval": [{ "field": "weeks", "triggerAtDay": [0], "triggerAtHour": 18 }] }
      },
      "id": "5a1f0c3e-0001-4000-8000-000000000001",
      "name": "Every Sunday 6 pm",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [0, 0]
    },
    {
      "parameters": {
        "url": "https://api.aceversity.com/v1/agenda",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendQuery": true,
        "queryParameters": { "parameters": [{ "name": "days", "value": "7" }] },
        "options": {}
      },
      "id": "5a1f0c3e-0002-4000-8000-000000000002",
      "name": "Aceversity: agenda",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [220, 0]
    },
    {
      "parameters": {
        "url": "https://api.aceversity.com/v1/practice/stats",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendQuery": true,
        "queryParameters": { "parameters": [{ "name": "days", "value": "30" }] },
        "options": {}
      },
      "id": "5a1f0c3e-0003-4000-8000-000000000003",
      "name": "Aceversity: weak topics",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [440, 0]
    },
    {
      "parameters": {
        "jsCode": "const agenda = $('Aceversity: agenda').first().json;\nconst stats = $input.first().json;\nconst lines = [`Your week (${agenda.today} → ${agenda.until})`, ''];\nfor (const i of agenda.items) lines.push(`• ${i.due_on} — ${i.course_name}: ${i.title} (${i.kind}, in ${i.days_until} days)`);\nif (!agenda.items.length) lines.push('• Nothing due — a good week to get ahead.');\nconst todo = agenda.milestones.filter((m) => !m.done);\nif (todo.length) {\n  lines.push('', 'Study-plan steps:');\n  for (const m of todo) lines.push(`• ${m.overdue ? '⚠️ overdue ' : ''}${m.due_on ?? ''} ${m.title} (${m.item_title})`);\n}\nif (stats.weak_topics.length) {\n  lines.push('', 'Review these topics:');\n  for (const t of stats.weak_topics.slice(0, 5)) lines.push(`• ${t.topic} — ${t.percent}% over ${t.attempts} answers`);\n}\nlines.push('', `Streak: ${stats.streak} days`);\nreturn [{ json: { subject: 'Your Aceversity week', text: lines.join('\\n') } }];"
      },
      "id": "5a1f0c3e-0004-4000-8000-000000000004",
      "name": "Build digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [660, 0]
    }
  ],
  "connections": {
    "Every Sunday 6 pm": { "main": [[{ "node": "Aceversity: agenda", "type": "main", "index": 0 }]] },
    "Aceversity: agenda": { "main": [[{ "node": "Aceversity: weak topics", "type": "main", "index": 0 }]] },
    "Aceversity: weak topics": { "main": [[{ "node": "Build digest", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" },
  "pinData": {}
}
