Skip to main content
GET
/
dashboard
/
daily
Dashboard Daily Stats
curl --request GET \
  --url https://api.example.com/dashboard/daily
{
  "error": "Invalid API Key"
}

Overview

Returns daily completed and failed job counts for the last 7 days. Used to render the dashboard chart.

Request

No query parameters required. Authentication via x-api-key header.

Response

daily_stats
array
Array of daily statistics (7 days)
daily_stats[].date
string
Date in YYYY-MM-DD format
daily_stats[].completed
integer
Number of jobs completed on this day
daily_stats[].failed
integer
Number of jobs failed on this day

Example

curl -X GET "https://tornado.velys.software/dashboard/daily" \
  -H "x-api-key: sk_your_api_key"

Error Responses

{
  "error": "Invalid API Key"
}

Chart Integration

This endpoint is designed for use with Chart.js or similar charting libraries:
async function loadDailyChart(apiKey) {
  const response = await fetch('/dashboard/daily', {
    headers: { 'x-api-key': apiKey }
  });
  const data = await response.json();

  const labels = data.daily_stats.map(d => {
    const date = new Date(d.date);
    return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
  });

  const completed = data.daily_stats.map(d => d.completed);
  const failed = data.daily_stats.map(d => d.failed);

  new Chart(ctx, {
    type: 'line',
    data: {
      labels: labels,
      datasets: [
        {
          label: 'Completed',
          data: completed,
          borderColor: '#00ff88',
          backgroundColor: 'rgba(0, 255, 136, 0.1)',
          fill: true
        },
        {
          label: 'Failed',
          data: failed,
          borderColor: '#ff3366',
          backgroundColor: 'rgba(255, 51, 102, 0.1)',
          fill: true
        }
      ]
    }
  });
}

Data Retention

Daily statistics are stored in Redis with an 8-day TTL. This ensures:
  • Always 7 days of history available
  • Automatic cleanup of old data
  • Fast retrieval for dashboard
If no jobs were processed on a given day, the count will be 0 (not missing from the array).

Use Cases

function analyzeTrends(stats) {
  const avgCompleted = stats.reduce((a, b) => a + b.completed, 0) / stats.length;
  const avgFailed = stats.reduce((a, b) => a + b.failed, 0) / stats.length;
  const failureRate = avgFailed / (avgCompleted + avgFailed) * 100;

  return {
    averageDaily: Math.round(avgCompleted),
    failureRate: failureRate.toFixed(2) + '%'
  };
}

Alerting on High Failure Rate

function checkFailureRate(stats) {
  const today = stats[stats.length - 1];
  const total = today.completed + today.failed;

  if (total > 0) {
    const rate = today.failed / total;
    if (rate > 0.1) { // 10% threshold
      alert(`High failure rate today: ${(rate * 100).toFixed(1)}%`);
    }
  }
}