#!/bin/bash # CURL käsk transport_context sisestamisega - LIHTSUSTATUD VERSIOON # Kasutab jq-d JSON-i formateerimiseks # Salvestatakse markdown faili ja eksporditud PDF-ks VS Code Markdown PDF laiendusega set -e GRAPHQL_URL="http://100.80.222.54:9020/v1/graphql" OUTPUT_FILE="$HOME/Downloads/articles_with_transport_context.md" echo "📡 Toon artikleid GraphQL API-st..." curl -s "$GRAPHQL_URL" \ -X POST \ -H "Content-Type: application/json" \ -d '{ "query": "{ Get { ScientificArticle { title source_file summary_et transport_context } } }" }' \ | jq -r ' "\n\n# Teadusartiklite analüüs\n\nEksporditud: " + (now | strftime("%d.%m.%Y %H:%M")) + "\n\n---\n\n", (.data.Get.ScientificArticle[] | "\n## " + .title + "\n\n" + "**Allikfail:** `" + (.source_file | split("/") | .[-1]) + "`\n\n" + "### Kokkuvõte (eesti keeles)\n\n" + .summary_et + "\n\n" + "### Transpordiplaneerimise kontekst\n\n" + ( if .transport_context then ( .transport_context | if type == "string" then ( gsub("```json\\s*"; "") | gsub("\\s*```"; "") | . ) else @json end ) else "Andmeid pole saadaval" end ) + "\n\n---\n" )' \ > "$OUTPUT_FILE" if [ -f "$OUTPUT_FILE" ]; then echo "✅ Markdown fail salvestatud: $OUTPUT_FILE" echo "" echo "🚀 Järgmised sammud:" echo " 1. Avage fail VS Code'is: code $OUTPUT_FILE" echo " 2. Paremklõps failil → 'Markdown PDF: Export (pdf)'" echo " 3. PDF fail luuakse samasse kausta" echo "" echo "💡 Juhised: Vaata README_CURL_TRANSPORT_CONTEXT.md" else echo "❌ Viga: markdown faili ei õnnestunud luua" exit 1 fi