<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Dataset Status API | Trongcaykhoe.pro</title>
    <meta name="robots" content="noindex">
    <script>
        const API_BASE = 'tables/plant_logs';
        const SITE_URL = 'https://trongcaykhoe.pro';
        
        async function getStatus() {
            try {
                const response = await fetch(`/${API_BASE}?page=1&limit=1&sort=-log_date`);
                
                if (!response.ok) {
                    throw new Error(`API Error: ${response.status}`);
                }
                
                const data = await response.json();
                
                const status = {
                    "status": "active",
                    "dataset": {
                        "name": "Plant Health Experiment Log",
                        "description": "Real-world observations about plant health, soil improvement, and ecological gardening",
                        "url": `${SITE_URL}/api/dataset.json`,
                        "format": "JSON-LD (Schema.org)",
                        "license": "CC BY 4.0"
                    },
                    "statistics": {
                        "totalLogs": data.total || 0,
                        "lastUpdated": data.data?.[0]?.log_date || null,
                        "lastLogId": data.data?.[0]?.log_id || null,
                        "firstLogDate": "2024-02-01",
                        "updateFrequency": "2-3 observations per week"
                    },
                    "author": {
                        "name": "Dao Manh Toan (A Toan)",
                        "website": "https://ipexperiment.com"
                    },
                    "location": {
                        "name": "BrainFarm",
                        "address": "Di Linh, Lam Dong, Vietnam",
                        "elevation": "900m",
                        "climate": "Subtropical highland",
                        "soilType": "Red basalt (bazan)"
                    },
                    "focus": {
                        "primary": "Plant health and soil improvement",
                        "topics": [
                            "Soil restoration", "Organic matter management",
                            "Companion planting", "Natural pest control",
                            "Composting", "Mulching", "EM application"
                        ]
                    },
                    "ecosystem": {
                        "name": "IP Experiment",
                        "hub": "https://ipexperiment.com",
                        "totalProjects": 18
                    },
                    "endpoints": {
                        "liveData": `${SITE_URL}/api/dataset.json`,
                        "status": `${SITE_URL}/api/dataset-status.json`,
                        "experimentLog": `${SITE_URL}/experiment-log.html`,
                        "aiGuide": `${SITE_URL}/llms.txt`
                    },
                    "apiInfo": {
                        "version": "1.0",
                        "generated": new Date().toISOString()
                    }
                };
                
                document.body.innerHTML = '<pre style="white-space: pre-wrap; font-family: monospace; font-size: 14px; padding: 20px; background: #f5f5f5;">' + 
                    JSON.stringify(status, null, 2) + '</pre>';
                    
            } catch (error) {
                console.error('Status error:', error);
                document.body.innerHTML = '<pre style="color: red; padding: 20px;">{"error": "' + error.message + '"}</pre>';
            }
        }
        
        window.onload = getStatus;
    </script>
</head>
<body style="margin: 0; padding: 0;">
    <p style="padding: 20px;">Loading dataset status...</p>
</body>
</html>
